反向代理跳转

来自linux中国网wiki
跳转至: 导航搜索
  1. 注意 这个是老的版本

新的请见 nginx反向代理跳转 反向代理跳转

苹果审核因为网络问题而不成功

国内的域名是inland.game.com

想让ios客户端做检查 ,当连接inland.game.com  不通时,就先去abroad.game.com(此机器在海外), 然后从这个域名再代理回国内inland.game.com

 

过程 一开始 upstream不是放在 nginx.conf 老是不行 ,带不了参数 (sdk) 后来强哥说加后端 我也加了 不过最后是 1.放nginx.conf 2.upstream sdk的 我好像写错了

[root@_test hosts]# tail ../nginx.conf -n 20

 

        upstream sdk.52wan.net {
                server sdk.52wan.net:443;
        }

        upstream api.52wan.net {
                server api.52wan.net:443;
        }





 include /nginx/conf/hosts/*.conf;

}

;

[root@_test hosts]# cat sdk2for52wan.conf

        server {
               listen  443 ssl;
               server_name   sdk2.net;

               error_log /data/logs/nginx/sdk_error.log;
               access_log  /data/logs/nginx/sdk2for52wan_access.log  main;

               ssl_certificate     /data/.net.crt;
               ssl_certificate_key /data/m.net.key;
                ssl_protocols       TLSv1 TLSv1.1 TLSv1.2;
               ssl_ciphers         HIGH:!aNULL:!MD5;
               charset utf-8;



                  # Gzip Compression
    gzip on;
    gzip_comp_level 6;
    gzip_vary on;
    gzip_min_length  1000;
    gzip_proxied any;
    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
    gzip_buffers 16 8k;

               # proxy_redirect off;

         location / {
                           proxy_pass        [https://sdk.52wan.net https://sdk.52wan.net];
        proxy_set_header   Host             $host;
        proxy_set_header   X-Real-IP        $remote_addr;
        proxy_set_header   X-Server-PORT    $server_port;
        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
        proxy_set_header Accept-Encoding  'gzip' ;
        client_max_body_size    10m;
        client_body_buffer_size 128k;
        proxy_connect_timeout   90;
        proxy_send_timeout      90;
        proxy_read_timeout      90;
        proxy_buffer_size       4k;
        proxy_buffers           4 32k;
        proxy_busy_buffers_size 64k;
        proxy_temp_file_write_size 64k;
        proxy_ignore_client_abort on;
                        #proxy_store off;
                      #  proxy_set_header X-Real-IP $remote_addr;
        # proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        # proxy_set_header Host $http_host;
        # proxy_set_header X-NginX-Proxy true;



        ##by evan 后来这个rewrite 是我关了就好了的 领导 乱说 
        index  index.php index.html index.htm;
        #if (!-e $request_filename ){
        #    rewrite ^/index.php/(.*)$ /index.php?s=$1 last;
        #    rewrite ^(.*)$ /index.php?s=$1 last;
        #}
        if ($request_method !~ ^(GET|HEAD|POST)$ )
        {
            return 444;
        }
        keepalive_timeout  0;

        ## by evan
       #access_log /dev/null main;
       #error_log /data/logs/nginx/sdk_error.log;
       #access_log  /data/logs/nginx/sdk2for52wan_access.log  main;
       #proxy_pass [https://sdk.52wan.net https://sdk.52wan.net];
       #proxy_redirect off;
                }
        }



[root@_test hosts]# cat api2for52wan.conf

      # LB for abroad.game.com
      #  upstream api.52wan..net {
      #          server api.52wannet:443;
      #  }

        server {
                listen  443 ssl;
                server_name   api2.net;
               ssl_certificate     /data/mon/dkmol.net.crt;
               ssl_certificate_key /data/mon/dkmol.net.key;
                ssl_protocols       TLSv1 TLSv1.1 TLSv1.2;
               ssl_ciphers         HIGH:!aNULL:!MD5;
               charset utf-8;

                proxy_redirect off;

                location / {
                        proxy_store off;
                        #access_log /dev/null main;
                        access_log  /data/logs/nginx/api2for52wan_access.log  main;
                        proxy_pass [https://api.52wan.dkmol.net https://api.52wan.dkmol.net];
                }
        }

nginx常用代理配置 http://www.cnblogs.com/fanzhidongyzby/p/5194895.html

nginx做反向代理proxy_pass,proxy_redirect的使用 http://www.snooda.com/read/253