nginx部署踩坑

 

 

复制代码
server {
    listen    80;
    server_name  localhost;
    ssl_session_timeout  5m;
    ssl_ciphers  HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers  on;
    large_client_header_buffers  4 32k;
    location /api/ {
            # 如果后端在本地比如127.0.0.1或者localhost请解开下面的rewrite注释即可
            # rewrite  ^.+api/?(.*)$ /$1 break;
            # 这里填写后端地址(后面一定不要忘记添加 / )
            proxy_pass http://192.168.5.67:5001/api/;
            proxy_set_header Host $host;
            proxy_set_header Cookie $http_cookie;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_redirect default;
            add_header Access-Control-Allow-Origin *;
            add_header Access-Control-Allow-Headers X-Requested-With;
            add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
    }


    location / {
        try_files $uri $uri/ @router;
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }
       location @router {
       rewrite ^.*$ /index.html last;
    }
}
复制代码

 

posted @   热心网友大熊  阅读(19)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
点击右上角即可分享
微信分享提示