server {
listen 80;
server_name ABC.com;
charset utf-8;
#access_log logs/host.access.log main;
location / {
try_files $uri $uri/ /index.html;#支持history模式刷新,解决前端history模式下,出现404
root /home/WebServer/dist;
index index.html index.htm;
}
location ^~ /apis/{#表示匹配apis
proxy_pass http://11.1.1.144:8080/;#后台服务,此处URL需要追加 “/” 转发请求到后台会去掉apis否则会保留apis
proxy_cookie_path / /;
proxy_set_header HOST $host;
proxy_set_header X-Real-IP $remote_addr;
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-For $remote_addr;
# proxy_cache_methods POST;
}
access_log /data/logs/nginx/ABC.com/access.log access;
error_log /data/logs/nginx/ABC.com/error.log error;
}