Nginx Reverse Proxy Golang Web

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

Existing two Golang Web service programs: web1 (8080), WEB2 (8081), two domain names:www.xxxxx.com, www.yyyy.com

On one machine, the xxxxx.com resolves to port 8080 and yyyy.com resolves to 8081 ports

Ways to reverse proxy using Nginx:

First, in the Nginx configuration file, add the following configuration

server{

Listen 80;

server_name www.xxxxx.com xxxxx.com;

Location/{

Try_files/_not_exists @backend;

}

Location @backend {

Proxy_set_header x-forwarded-for $remote _addr;

Proxy_set_header Host $http _host;

Proxy_pass http://localhost:8080;

}

}

Domain xxxxx.com,www.xxxxx.com can be resolved to server 8080 port

server{

Listen 80;

server_name www.yyyy.com yyyy.com;

Location/{

Try_files/_not_exists @backend;

}

Location @backend {

Proxy_set_header x-forwarded-for $remote _addr;

Proxy_set_header Host $http _host;

Proxy_pass http://localhost:8081;

}

}

Domain yyyy.com,www.yyyy.com can be resolved to server 8081 port.

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.