由于请求转发配置出问题最多,附一份完整的nginx配置(除52-54行外全部为默认配置)

    1. # For more information on configuration, see:
    2. # * Official English Documentation: http://nginx.org/en/docs/
    3. # * Official Russian Documentation: http://nginx.org/ru/docs/
    4. user root;
    5. worker_processes auto;
    6. error_log /var/log/nginx/error.log;
    7. pid /run/nginx.pid;
    8. # Load dynamic modules. See /usr/share/nginx/README.dynamic.
    9. include /usr/share/nginx/modules/*.conf;
    10. events {
    11. worker_connections 1024;
    12. }
    13. http {
    14. log_format main '$remote_addr - $remote_user [$time_local] "$request" '
    15. '$status $body_bytes_sent "$http_referer" '
    16. '"$http_user_agent" "$http_x_forwarded_for"';
    17. access_log /var/log/nginx/access.log main;
    18. sendfile on;
    19. tcp_nopush on;
    20. tcp_nodelay on;
    21. gzip on;
    22. gzip_types text/plain application/x-javascript text/css application/xml;
    23. keepalive_timeout 65;
    24. types_hash_max_size 2048;
    25. include /etc/nginx/mime.types;
    26. default_type application/octet-stream;
    27. # Load modular configuration files from the /etc/nginx/conf.d directory.
    28. # See http://nginx.org/en/docs/ngx_core_module.html#include
    29. # for more information.
    30. include /etc/nginx/conf.d/*.conf;
    31. server {
    32. listen 80 default_server;
    33. listen [::]:80 default_server;
    34. server_name _;
    35. root /usr/share/nginx/html;
    36. # Load configuration files for the default server block.
    37. include /etc/nginx/default.d/*.conf;
    38. location / {
    39. }
    40. location /wx {
    41. proxy_pass http://127.0.0.1:8088/wx;
    42. }
    43. }
    44. }

    需注意proxy_pass不可随意添加/,加了有不同含义