nginx配置多个网站
主 的配置
server {
listen 80;
server_name localhost;
#vue项目配置
location / {
root /usr/local/java/web/fsai-ui/dist/;
try_files $uri $uri/ /index.html;
index index.html index.htm;
}
#后端接口服务 的配置
location /prod-api/{
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:8080/; #设置监控后端启动的端口
}
location /web2/{
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:8009/; #设置监控后端启动的端口
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
配置多个server 转发
server {
listen 8009;
server_name www.zk2308.com;
location / {
root /myweb/myweb1/;
index index.html index.htm;
}
}