整理了Nginx的一些相关配置,有需要配置的时候可以方便查看一下
1、使用同一个端口配置多个站点
server {
listen 8080;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
#加下面的配置
location /baidu{
proxy_pass http://localhost:8081/bob/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 100m;
root html;
index index.html index.htm;
}
location /taobao{
proxy_pass http://localhost:8082/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 100m;
root html;
index index.html index.htm;
}
}