中文说明文档

https://docshome.gitbook.io/nginx-docs/readme/chu-xue-zhe-zhi-nan

重新加载配置文件 -c 指定自定义配置文件
nginx -s reload

验证默认配置文件
nginx -t
验证自定义配置文件
nginx -t -c /home/test/conf/nginx.conf

  1. upstream xckefu {
  2. server 111.229.106.32:8080;
  3. }
  4. server {
  5. listen 80;
  6. server_name localhost;
  7. location /xckefu {
  8. proxy_pass http://xckefu;
  9. # 这三行解决,当请求被srping 拦截器拦截后,通过request拿到的server是代理地址 xckefu,而不是实际请求地址的问题
  10. proxy_redirect off;
  11. proxy_set_header Host $http_host;
  12. proxy_set_header X-Real-IP $remote_addr;
  13. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  14. }
  15. location /abc {
  16. root /usr/share/nginx/html/dist;
  17. #root这里填了容器中的绝对路径 请求的是 /usr/share/nginx/html/dist/abc/index.html
  18. #我填相对路径如html/dist时
  19. #容器会去/etc/nginx/html/dist/abc找 index.html
  20. index index.html index.htm;
  21. }
  22. }