安装 nginx
yum installl -y nginx
配置 conf
cd /etc/nignx/conf.d
vim xxx.conf
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;
}
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;
...
}