适用场景:利用一个Nginx,即可把Java、PHP、Python等项目统一起来。

    下面的代码意思就是说,如果你访问 http://pic.example.top,就等同于访问 http://xxx.xx.xx.xx:8041。

    1. upstream flow_server {
    2. server 127.0.0.1:8041;
    3. }
    4. server {
    5. listen 80;
    6. server_name pic.example.top;
    7. # root /var/www/smpp;
    8. #location /smpp {
    9. # add_header Access-Control-Allow-Origin *;
    10. # add_header Access-Control-Allow-Headers X-Requested-With;
    11. # add_header Access-Control-Allow-Methods GET,POST,OPTOPNS;
    12. #
    13. # proxy_set_header X-Real-IP $remote_addr;
    14. # proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    15. # proxy_set_header Host $http_host;
    16. #}
    17. location / {
    18. proxy_pass http://127.0.0.1:8041;
    19. index index.html;
    20. try_files /index.html =404;
    21. }
    22. location = /favicon.ico {
    23. try_files $uri $uri/;
    24. }
    25. }