nginx配置反向代理,解决前端开发的跨域问题

适用:开发和生产环境

配置如下

server {
        listen       10901;
        server_name  res.pre.ices.red;
        #charset koi8-r;
        #access_log  logs/res.access.log  main;

        location / {
        client_max_body_size        100m;
        client_body_temp_path    /tmp/nginx_temp;
        dav_methods            PUT DELETE MKCOL COPY MOVE;
            create_full_put_path       on;
            dav_access                 group:rw  all:r;
            root                /data/yhqz-resource/tiandun;
            index              index.html index.htm;
        }
      location /api {
             proxy_set_header X-Real-IP $remote_addr;
             rewrite  ^.+api/?(.*)$ /$1 break;
             include  uwsgi_params;
             proxy_pass   http://192.168.0.93:8888;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

    }
 

 参考文档:https://www.cnblogs.com/Miss-mickey/p/6734831.html

posted @ 2017-09-19 15:04  zph前端  阅读(369)  评论(0编辑  收藏  举报