当前位置:   article > 正文

nginx upstream 配置_nginx upstream配置

nginx upstream配置

安装 nginx

yum installl -y nginx
  • 1

配置 conf

cd /etc/nignx/conf.d
vim xxx.conf
  • 1
  • 2
upstream tcs {
    server x.x.x.x:80;
}

server {
    listen 80;
    server_name 域名1 域名2 域名3;
    location / {
        proxy_pass http://tcs;
        proxy_redirect off;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $http_host;
    }

   error_page  404    /404.html;
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17

FAQ

如果设置多域名,这里会报错:could not build server_names_hash, you should increase server_names_hash_bucket_size: 64
需要修改 /etc/nginx/nginx.conf

http {
	...
    server_names_hash_bucket_size  128;
    ...
}
  • 1
  • 2
  • 3
  • 4
  • 5
声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop】
推荐阅读
相关标签
  

闽ICP备14008679号