记录一个nginx反向代理案例

ixibei 发表于 分类:Nginx 阅读(210) 评论(0)

简介:

nginx 发现代理在实际运用中非常的广泛,下面记载一个nginx的反向代理实例,可以参考一下实例学习nginx反向代理哦!server {    listen 443;    ssl on…

nginx 发现代理在实际运用中非常的广泛,下面记载一个nginx的反向代理实例,可以参考一下实例学习nginx反向代理哦!

server {

    listen 443;

    ssl on;

    ssl_certificate   /usr/local/nginx/conf/cert/test/www.pem;

    ssl_certificate_key  /usr/local/nginx/conf/cert/test/www.key;

    ssl_session_timeout 5m;

    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

    ssl_prefer_server_ciphers on;

    server_name  www.test.com;


access_log  /home/logs/test.www.access.log;


    include /etc/nginx/default.d/*.conf;

   

root   /home/www/test/public;

index  index.php;

location = / {

try_files $uri $uri/ /index.php?$query_string;

}


location ~* (\/app|\/ios|\/com|\/news|\/topic|\/rank|\/down|\/footer|\/xml|\/favicon|\/zjbb|\/xxbb|\/xbbb|\/static|\/uploads|\/hits\/|\/pks\/) {

try_files $uri $uri/ /index.php?$query_string;

    }


location / {

charset utf-8;

proxy_redirect off;

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-Forwarded-Proto $scheme;

proxy_set_header X-NginX-Proxy true;

proxy_set_header Connection "";

proxy_http_version 1.1;

proxy_pass   https://xx.xx.xx.xx/;

}

location = /portal.php {

charset utf-8;

proxy_redirect off;

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-Forwarded-Proto $scheme;

proxy_set_header X-NginX-Proxy true;

proxy_set_header Connection "";

proxy_http_version 1.1;

proxy_pass   https://xx.xx.xx.xx/;

}

location = /forum.php {

charset utf-8;

proxy_redirect off;

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-Forwarded-Proto $scheme;

proxy_set_header X-NginX-Proxy true;

proxy_set_header Connection "";

proxy_http_version 1.1;

proxy_pass   https://xx.xx.xx.xx/;

}

location = /search.php {

charset utf-8;

proxy_redirect off;

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-Forwarded-Proto $scheme;

proxy_set_header X-NginX-Proxy true;

proxy_set_header Connection "";

proxy_http_version 1.1;

proxy_pass   https://xx.xx.xx.xx/;

}

location = /misc.php {

charset utf-8;

proxy_redirect off;

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-Forwarded-Proto $scheme;

proxy_set_header X-NginX-Proxy true;

proxy_set_header Connection "";

proxy_http_version 1.1;

proxy_pass   https://xx.xx.xx.xx/;

}

location = /home.php {

charset utf-8;

proxy_redirect off;

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-Forwarded-Proto $scheme;

proxy_set_header X-NginX-Proxy true;

proxy_set_header Connection "";

proxy_http_version 1.1;

proxy_pass   https://xx.xx.xx.xx/;

}



    location ~ \.php$ {

        root           /home/www/test/public;

        fastcgi_pass   127.0.0.1:9000;

        fastcgi_index  index.php;

        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

        include        fastcgi_params;

    }

}



结束语

本文有任何错误,或有任何疑问,欢迎留言说明。

本站文章除注明转载外,均为原创文章,会经常更新知识点以及修正一些错误,因此转载请保留原出处,方便溯源,避免陈旧错误知识的误导,同时有更好的阅读体验。

http://www.onephper.com/archive/54.html

相关推荐

评论

回复给XXX取消回复

说点什么吧...

网友最新评论

输入关键字