1. user root;
    2. worker_processes 1;
    3. #error_log logs/error.log;
    4. #error_log logs/error.log notice;
    5. #error_log logs/error.log info;
    6. #pid logs/nginx.pid;
    7. events {
    8. worker_connections 1024;
    9. }
    10. http {
    11. include mime.types;
    12. default_type application/octet-stream;
    13. #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
    14. # '$status $body_bytes_sent "$http_referer" '
    15. # '"$http_user_agent" "$http_x_forwarded_for"';
    16. #access_log logs/access.log main;
    17. sendfile on;
    18. #tcp_nopush on;
    19. #keepalive_timeout 0;
    20. keepalive_timeout 65;
    21. #gzip on;
    22. server {
    23. listen 80;
    24. server_name localhost;
    25. #charset koi8-r;
    26. #access_log logs/host.access.log main;
    27. location / {
    28. root /root/zx/vgc/dist;
    29. index index.html index.htm;
    30. try_files $uri $uri/ @router; # 需要指向下面的@router否则会出现vue的路由在nginx中刷新出现404
    31. }
    32. location @router {
    33. rewrite ^.*$ /index.html last;
    34. }
    35. location /api {
    36. proxy_pass http://132.126.3.223:9114/;
    37. }
    38. #error_page 404 /404.html;
    39. # redirect server error pages to the static page /50x.html
    40. #
    41. error_page 500 502 503 504 /50x.html;
    42. location = /50x.html {
    43. root html;
    44. }
    45. # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    46. #
    47. #location ~ \.php$ {
    48. # proxy_pass http://127.0.0.1;
    49. #}
    50. # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    51. #
    52. #location ~ \.php$ {
    53. # root html;
    54. # fastcgi_pass 127.0.0.1:9000;
    55. # fastcgi_index index.php;
    56. # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
    57. # include fastcgi_params;
    58. #}
    59. # deny access to .htaccess files, if Apache's document root
    60. # concurs with nginx's one
    61. #
    62. #location ~ /\.ht {
    63. # deny all;
    64. #}
    65. }
    66. # another virtual host using mix of IP-, name-, and port-based configuration
    67. #
    68. #server {
    69. # listen 8000;
    70. # listen somename:8080;
    71. # server_name somename alias another.alias;
    72. # location / {
    73. # root html;
    74. # index index.html index.htm;
    75. # }
    76. #}
    77. # HTTPS server
    78. #
    79. #server {
    80. # listen 443 ssl;
    81. # server_name localhost;
    82. # ssl_certificate cert.pem;
    83. # ssl_certificate_key cert.key;
    84. # ssl_session_cache shared:SSL:1m;
    85. # ssl_session_timeout 5m;
    86. # ssl_ciphers HIGH:!aNULL:!MD5;
    87. # ssl_prefer_server_ciphers on;
    88. # location / {
    89. # root html;
    90. # index index.html index.htm;
    91. # }
    92. #}
    93. }