Nginx Reverse proxy settings

Source: Internet
Author: User
Tags nginx reverse proxy
Background of Nginx Reverse proxy settings: 1. the web programs developed by the US team are deployed on a server, the old GlassFish2.x, or windows, which is called App1. 2. our newly developed web program is deployed on another server, Ubuntu12.04server, the new version of GlassFish3.x, takes... nginx Reverse proxy settings background: 1. the web programs developed by the U.S. team are deployed on a server, the old GlassFish2.x or windows, which is called App1. 2. the newly developed web application is deployed on another server, Ubuntu12.04 server, and the new version of GlassFish3.x, which is called App2. Www.2cto.com: If you want to disguise these two programs as a site, you can solve the following two problems:
1. for authentication problems, the browser first logs in from App1 and saves the cookie. Then, when you access App2, the cookie will be sent. App2 performs user identity authentication by parsing the token in the cookie. if there is no token or no cookie, login is required to automatically switch to App1. Otherwise, after obtaining the token, the server calls the App1 verification API to check whether the user's session has expired. 2. support for HTTP/HTTPS at the same time, because login and other sensitive requests need to be encrypted. The following figure is helpful for understanding me:
How to configure it? write the configuration in an independent conf file, which consists of two parts. [plain] server {listen 80; server_name 192.168.1.10; access_log/opt/agol_http.log my_log; location ^ ~ /Home {proxy_pass http://192.168.1.11 ; Proxy_set_header Host $ host; proxy_set_header X-Forwarded-For $ proxy_add_x_forwarded_for;} www.2cto.com location ^ ~ /Sharing {proxy_pass http://192.168.1.11 ; Proxy_set_header Host $ host; proxy_set_header X-Forwarded-For $ proxy_add_x_forwarded_for;} location/geoflow {proxy_pass http://192.168.1.10:8081/flow ; Proxy_set_header Host $ host; proxy_set_header X-Forwarded-For $ proxy_add_x_forwarded_for;} [plain]} HTTPS also separately configures a Server [plain] # HTTPS server {listen 443 ssl; ssl_certificate/usr/nginx/conf/server. crt; ssl_certificate_key/usr/nginx/conf/server. key; server_name 10.112.18.178; access_log/opt/agol_https.log my_log; location/{www.2cto.com proxy_pass https://192.168.1.11 ; Proxy_set_header Host $ host; proxy_set_header X-Forwarded-For $ proxy_add_x_forwarded_for ;}} so that Nginx can see that if it is an HTTPS request, all requests are switched to app1. If it is an HTTP request, it depends on the URL. depending on the location, it is decided to switch to different applications. This configuration is flexible. Add include agol. conf; in the http settings of nginx. conf. Author: sheismylife
Related Article

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.