nginx反向代理https站点
基本的代理配置就不說了 現在貼出配置并強調幾點容易出錯的問題。
user ? ? ? ? ? ? ?nginx;
worker_processes ?1;
error_log ?/var/log/nginx/error.log;
pid ? ? ? ?/var/run/nginx.pid;
events {
? ? worker_connections ?1024;
}
http {
? ? include ? ? ? /etc/nginx/mime.types;
? ? default_type ?application/octet-stream;
? ? log_format ?main ?'$remote_addr - $remote_user [$time_local] "$request" '
? ? ? ? ? ? ? ? ? ? ? '$status $body_bytes_sent "$http_referer" '
? ? ? ? ? ? ? ? ? ? ? '"$http_user_agent" "$http_x_forwarded_for"';
? ? access_log ?/var/log/nginx/access.log ?main;
? ? sendfile ? ? ? ?on;
? ? keepalive_timeout ?65;
server {
? ? ? ? listen ? ? ? 80;
? ? ? ? server_name ?aaa.test.com;
? ? ? ? rewrite ^(.*) https://$server_name$1 permanent;
? ? }????????? ??##這一塊用來指定rewrite
? ? server {
? ? ? ? listen ? ? ? 443;
? ? ? ? server_name ?aaa.test.com;????????##如果后端是多vhost的server此處必須用真實域名。
? ? ? ? location / {
? ? ? ? ? ? ? ?proxy_pass https://172.16.160.131;? ? ?##realserver真實地址或域名
? ? ? ? ? ? ? ?proxy_set_header ?Host $host;
? ? ? ? ? ? ? ?proxy_set_header ?X-Real-IP ?$remote_addr;
? ? ? ? ? ? ? ?proxy_set_header ?X-Forwarded-For $proxy_add_x_forwarded_for;
? ? ? ? ? ? ? ?client_max_body_size 100m;
? ? ? ? ? ? ? ?client_body_buffer_size 128k;
? ? ? ? ? ? ? ?proxy_connect_timeout 300;
? ? ? ? ? ? ? ?proxy_send_timeout 300;
? ? ? ? ? ? ? ?proxy_read_timeout 300;
? ? ? ? ? ? ? ?proxy_buffer_size 4k;
? ? ? ? ? ? ? ?proxy_buffers 4 32k;
? ? ? ? ? ? ? ?proxy_busy_buffers_size 64k;
? ? ? ? ? ? ? ?proxy_temp_file_write_size 64k;
? ? ? ? ? ? ? ?add_header X-Frame-Options SAMEORIGIN;
? ? ? }
? ? ? ssl ? ? ? ? ? ? ? ? ?on;
? ? ? ssl_certificate ? ? ?/etc/nginx/cert/server.crt;?????##此處是realserver的站點證書,用自簽返回的就是自簽。
? ? ? ssl_certificate_key ?/etc/nginx/cert/server.key;
? ? ? ssl_session_timeout ?5m;
? ? ? ssl_protocols ?SSLv3 TLSv1;
? ? ? ssl_ciphers ?ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
? ? ? ssl_prefer_server_ciphers ? on;
? ? ? error_page ? 500 502 503 504 ?/50x.html;
? ? ? location = /50x.html {
? ? ? ? ? root ? html;
? ? ? }
? ?}
? ? include /etc/nginx/conf.d/*.conf;
}
本文轉自 轉身撞墻角 51CTO博客,原文鏈接:http://blog.51cto.com/chentianwang/1825936
總結
以上是生活随笔為你收集整理的nginx反向代理https站点的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Silverlight 4 新特性之Si
- 下一篇: 运维自动化—ansible的使用