The basic proxy configuration is not said now post configuration and highlight a few error-prone issues.
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的站点证书, returning with self-signed is self-signed.
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 502 503 504/50x.html;
Location =/50x.html {
root HTML;
}
}
include/etc/nginx/conf.d/*.conf;
}
Nginx Reverse Proxy HTTPS site