web前段跨域nginx代理配置


nginx代理配置可参考server部分

server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;
       
       
        location /v1/ {
            proxy_redirect     off;
            #rewrite /v1/(.*) /$1 break;

            add_header 'Access-Control-Allow-Origin'      '*';
#add_header 'Access-Control-Allow-Credentials' 'true';
            add_header 'Access-Control-Allow-Headers'     'x-requested-with,content-type';
            add_header 'Access-Control-Allow-Methods'     'OPTIONS,GET,POST';


            proxy_set_header   Host             $host;
            proxy_set_header   X-Real-IP        $remote_addr;
            proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
            proxy_set_header   x-request-uri    $request_uri;



            proxy_connect_timeout      120;
            proxy_send_timeout         120;
            proxy_read_timeout         120;

            client_max_body_size 2048M;

            proxy_pass http://192.168.3.36:8006;
        }


        location /cms{ 
            alias e:\ceshi_temp\cms;
        }

        location /active/ {
            proxy_redirect     off;
            #rewrite /v1/(.*) /$1 break;

            add_header 'Access-Control-Allow-Origin'      '*';
#add_header 'Access-Control-Allow-Credentials' 'true';
            add_header 'Access-Control-Allow-Headers'     'x-requested-with,content-type';
            add_header 'Access-Control-Allow-Methods'     'OPTIONS,GET,POST';


            proxy_set_header   Host             $host;
            proxy_set_header   X-Real-IP        $remote_addr;
            proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
            proxy_set_header   x-request-uri    $request_uri;



            proxy_connect_timeout      120;
            proxy_send_timeout         120;
            proxy_read_timeout         120;

            client_max_body_size 2048M;

            proxy_pass http://192.168.3.33:8080;
        }

        location /shopping/ {
            proxy_redirect     off;
            rewrite /v1/(.*) /$1 break;

            add_header 'Access-Control-Allow-Origin'      '*';
            #add_header 'Access-Control-Allow-Credentials' 'true';
            add_header 'Access-Control-Allow-Headers'     'x-requested-with,content-type';
            add_header 'Access-Control-Allow-Methods'     'OPTIONS,GET,POST';


            proxy_set_header   Host             $host;
            proxy_set_header   X-Real-IP        $remote_addr;
            proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
            proxy_set_header   x-request-uri    $request_uri;



            proxy_connect_timeout      120;
            proxy_send_timeout         120;
            proxy_read_timeout         120;

            client_max_body_size 2048M;

            #proxy_pass http://192.168.3.33:8080;
proxy_pass http://localhost:8080/shopping/;
        }


        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

 
    }

你可能感兴趣的:(nginx,cms,Web)