You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
BookingHeChuanFront/docker/nginx/vhost/default.conf

30 lines
1.1 KiB
Plaintext

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

server {
listen 80;
server_name localhost;
root /var/www/html;
index index.php index.html index.htm;
access_log /dev/null;
error_log /var/log/nginx/default.error.log warn;
# redirect server error pages to the static page /50x.html
#
#error_page 500 502 503 504 /50x.html;
location / {
root /var/www/html;
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
try_files $uri $uri/ /index.html;
}
location /api {
#如果服务器要获取客户端真实IP可以用下三句设置主机头和客户端真实地址
proxy_set_header Host $http_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-Proto $scheme;
rewrite ^/api/(.*)$ /$1 break; #重写
proxy_pass http://host.docker.internal:5000; # docker内访问宿主机win或mac----注意宿主机需在hosts文件中增加一条 host.docker.internal 127.0.0.1
# proxy_pass http://host.docker.internal:5000; # 生产环境改成真实后端地址
}
}