通用的前端nginx配置

我就是我 2023-02-22 04:00 110阅读 0赞
  1. erver {
  2. listen 8090;
  3. # 请修改为项目环境域名
  4. set $domain_name xx.xx.com;
  5. error_log /xx/log/nginx/${domain_name}-error.log ;
  6. access_log /xx/log/nginx/${domain_name}-access.log;
  7. server_name $domain_name;
  8. set $html_dir /xx/bin/static/;
  9. root $html_dir;
  10. location / {
  11. alias $html_dir;
  12. index index.html index.htm;
  13. try_files $uri $uri/ @rewrites;
  14. }
  15. location @rewrites {
  16. rewrite ^(.+)$ /index.html last;
  17. }
  18. location ~ /index\.html {
  19. alias $html_dir/index.html;
  20. add_header Cache-Control 'no-cache, no-store, max-age=0';
  21. }
  22. }
  23. server {
  24. listen 8080;
  25. server_name xx.xx.cn;
  26. #charset koi8-r;
  27. #access_log logs/host.access.log main;
  28. location / {
  29. rewrite .* /index.html break;
  30. root /xx/static/;
  31. index index.html index.htm;
  32. }
  33. location ~* \.(gif|jpg|jpeg|png|css|js|ico)$ {
  34. root /xx/static/;
  35. autoindex on;
  36. }
  37. location = /index.html {
  38. root /xx/static/;
  39. rewrite .* / redirect;
  40. }
  41. location /fonts/ {
  42. root /xx/static/;
  43. autoindex on;
  44. }
  45. location /material/ {
  46. proxy_pass http://10.241.134.245:8090;
  47. }
  48. #error_page 404 /404.html;
  49. # redirect server error pages to the static page /50x.html
  50. #
  51. error_page 500 502 503 504 /50x.html;
  52. location = /50x.html {
  53. root html;
  54. }
  55. }

发表评论

表情:
评论列表 (有 0 条评论,110人围观)

还没有评论,来说两句吧...

相关阅读