当前的nginx配置如下:
server { listen 80; server_name localhost; location / { root /usr/share/nginx/html; index index.html index.htm; } location @router{ rewrite ^(.+)$ /index.html last; } }
遇到的问题是,当访问 http://localhost:80的时候是可以的,但访问除此之外的其他路由时遇到了502的问题
解决方案:+ try_files
server { listen 80; server_name localhost; location / { root /usr/share/nginx/html; index index.html index.htm; try_files $uri $uri/ @router; } location @router{ rewrite ^(.+)$ /index.html last; } }
即可