Configure nginx to differentiate access by China Telecom Netcom

Source: Internet
Author: User
Because the company's dns supports China Telecom Netcom's traffic distribution, a project uses this function to allow users to access the same link. The China Telecom ip Address can see one page and the China Netcom ip Address can see another one. The original configuration is to use the hosts of squid. The squid of China Netcom refers to the backend of the China Netcom page, and the squid of China Telecom refers to the backend of the China Telecom page. This practice has obvious disadvantages: 1. Life and death

Because the company's dns supports China Telecom Netcom's traffic distribution, a project uses this function to allow users to access the same link. The China Telecom ip Address can see one page and the China Netcom ip Address can see another one.

The original configuration is to use squIdHosts, Netcom's squid refers to the Netcom page background, and Telecom's squid refers to the telecom page background.

This practice has obvious disadvantages:

1. There must be two backend servers. Currently, different ports cannot be configured in squid2.5.

2. squid's hosts must have two copies, which is not conducive to management. If the front end is constantly expanded, this is another annoyance.

If the cache of this domain name China Netcom Telecom is directed to the middle-layer proxy, these problems are easily solved.

The configuration logic is not complex:

1. First, obtain the Client ip address. On the middle-layer proxy, the Client ip address is the Intranet ip address of the previous cache server, which is easy to differentiate.

2. Use a judgment statement to let them go all the way.

Configuration:

LoCatIon = /{
Proxy_pass http: // proDuCt.xxx.com;
INcLude proxy. conf;
If ($ remote_aDdR ~ ^ 192.168.1 ){
ReWrite^/$/A/last;
}
If ($ remote_addr ~ ^ 192.168.2 ){
Rewrite ^/$/B/last;
}
}

However, if there is no front-end cache, it is still impossible to make such a distinction.

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.