1. #user nobody;
    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 8080;
    24. server_name localhost;
    25. #charset koi8-r;
    26. # access_log logs/host.access.log main;
    27. root html; # 这里指定刚刚我们的文件夹
    28. # 总的项目路由,我偷懒直接写在了同一个文件
    29. # 如果有很多可以在配置多个 conf 文件,使用 include 关联进来
    30. location / {
    31. try_files $uri $uri/ /index.html; # 这里可以理解指定到 html 文件夹下的 index.html
    32. }
    33. # business
    34. # 这里就是刚刚我们在 vue 项目中 config/index.js 的配置 build.assetsPublicPath,
    35. # 也是 vue 项目中配置的 router 中的 base
    36. location ^~ /business {
    37. try_files $uri $uri/ /business/index.html; # 这里可以理解指定到 html 文件夹下 project1 文件夹 的 index.html
    38. }
    39. # customer
    40. # 这里是项目二的配置
    41. location ^~ /customer { #
    42. try_files $uri $uri/ /customer/index.html; # 这里可以理解指定到 html 文件夹下 project2 文件夹 的 index.html
    43. }
    44. #error_page 404 /404.html;
    45. # redirect server error pages to the static page /50x.html
    46. #
    47. error_page 500 502 503 504 /50x.html;
    48. location = /50x.html {
    49. root html;
    50. }
    51. # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    52. #
    53. #location ~ \.php$ {
    54. # proxy_pass http://127.0.0.1;
    55. #}
    56. # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    57. #
    58. #location ~ \.php$ {
    59. # root html;
    60. # fastcgi_pass 127.0.0.1:9000;
    61. # fastcgi_index index.php;
    62. # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
    63. # include fastcgi_params;
    64. #}
    65. # deny access to .htaccess files, if Apache's document root
    66. # concurs with nginx's one
    67. #
    68. #location ~ /\.ht {
    69. # deny all;
    70. #}
    71. }
    72. # another virtual host using mix of IP-, name-, and port-based configuration
    73. #
    74. #server {
    75. # listen 8000;
    76. # listen somename:8080;
    77. # server_name somename alias another.alias;
    78. # location / {
    79. # root html;
    80. # index index.html index.htm;
    81. # }
    82. #}
    83. # HTTPS server
    84. #
    85. #server {
    86. # listen 443 ssl;
    87. # server_name localhost;
    88. # ssl_certificate cert.pem;
    89. # ssl_certificate_key cert.key;
    90. # ssl_session_cache shared:SSL:1m;
    91. # ssl_session_timeout 5m;
    92. # ssl_ciphers HIGH:!aNULL:!MD5;
    93. # ssl_prefer_server_ciphers on;
    94. # location / {
    95. # root html;
    96. # index index.html index.htm;
    97. # }
    98. #}
    99. include servers/*;
    100. }

    image.png