Nginx Reverse Proxy HTTPS
First, agent Nginx open 80,443 port
############################################################################
# cat/etc/nginx/conf.d/nginx_http.conf
# set to go directly to HTTPS when accessing via HTTP domain name
server {
Listen 80;
server_name www.meteor-yu.com;
Rewrite ^/(. *) https://$server _name/$1 permanent;
}
# setting does not allow IP access
server {
Listen default_server;
server_name _;
return 403;
}
# Set up access to top-level domain via HTTP meteor-yu.com auto Jump HTTPS access www.meteor-yu.com this domain name
server {
Listen 80;
server_name meteor-yu.com;
return 301 Https://www.meteor-yu.com$request_uri;
}
############################################################################
Ii. creating a self-signed certificate
# cat/etc/nginx/conf.d/nginx_https.conf
# Create a self-signed certificate and add it to the configuration
server {
Listen 443;
server_name www.meteor-yu.com;
SSL on;
Ssl_certificate CONF.D/SERVER.CRT;
Ssl_certificate_key Conf.d/server.key;
Access_log/var/log/nginx/staff_assessing_system_access.log main;
Error_log/var/log/nginx/staff_assessing_system_error.log;
Location/{
Proxy_next_upstream http_502 http_504 error timeout invalid_header;
Proxy_ignore_client_abort on;
Proxy_connect_timeout 60s;
Proxy_read_timeout 5400s;
Proxy_send_timeout 5400s;
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_pass http://10.10.10.10:84; # Forward to the backend Web port, here is the background web is 84 port, background access is still HTTP
}
}
# do not allow HTTPS direct IP access
server {
Listen 443 default_server;
server_name _;
SSL on;
SSL_CERTIFICATE/ETC/NGINX_SSL/SERVER.CRT;
Ssl_certificate_key/etc/nginx_ssl/server.key;
return 403;
}
# Set up access to top-level domain via HTTPS meteor-yu.com automatically jump to www.meteor-yu.com this domain name
server {
Listen 443;
SSL on;
SSL_CERTIFICATE/ETC/NGINX_SSL/SERVER.CRT;
Ssl_certificate_key/etc/nginx_ssl/server.key;
server_name meteor-yu.com;
return 301 Https://www.meteor-yu.com$request_uri;
}
############################################################################
This article is from "Meteor Yu" blog, please be sure to keep this source http://8789878.blog.51cto.com/8779878/1853752
Nginx Reverse Proxy HTTPS