Nginx Reverse Proxy HTTPS

Source: Internet
Author: User
Tags nginx reverse proxy

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.