server { listen 3000; listen [::]:3000; server_name localhost; root /usr/share/nginx/html; index index.html index.htm; #charset koi8-r; #access_log logs/host.access.log main; #解决Router(mode: 'history')模式下,刷新路由地址不能找到页面的问题 location / { try_files $uri $uri @rewrites; # 开启缓存 location ~* ^.+\.(ico|gif|jpg|jpeg|png)$ { access_log off; expires 2d; } location ~* ^.+\.(css|js|txt|xml|swf|wav)$ { access_log off; expires 24h; } location ~* ^.+\.(html|htm)$ { expires 1h; } location ~* ^.+\.(eot|ttf|otf|woff|svg)$ { access_log off; expires max; } } location /edit { try_files $uri $uri @rewrites; # 开启缓存 location ~* ^.+\.(ico|gif|jpg|jpeg|png)$ { access_log off; expires 2d; } location ~* ^.+\.(css|js|txt|xml|swf|wav)$ { access_log off; expires 24h; } location ~* ^.+\.(html|htm)$ { expires 1h; } location ~* ^.+\.(eot|ttf|otf|woff|svg)$ { access_log off; expires max; } } location @rewrites { rewrite ^(.+)$ /index.html?s=$1 last; } # 后台服务配置,配置了这个location便可以通过访问 location ^~ /military { proxy_pass http://military-system:8049/military/; proxy_set_header Host $host:3000; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } }