Nginx + Apache Public 80 port configuration

Source: Internet
Author: User

A typical Nginx + Apache application scenario can be nginx occupying 80 ports, filtering static requests, and then dynamically requesting the Proxy to the Apache 8080 port. The advantage of proxy reverse proxies is that when access is always 80 port, visitors will not be aware of any difference.

However, some applications are very "smart", recognizing that Apache is located in the port is 8080, will be associated with the hyperlinks are added: 8080 of the follow-up. So you're dead, and you can have a normal visit?! There is a way to solve this problem, that is, Apache is also running on port 80.
The same server, there are nginx also apache,2 a httpd service, are 80, will not conflict?

The below is an example method.
Nginx.conf in the configuration
server {
Listen 80;
server_name www.ABC.com;

Root/var/www

}
Modify it a bit.
server {
Listen public network ip123.123.123.123:80; #指定Nginx只占用某个IP的80端口. #如果你服务器中有多个IP, you can also specify more than one.
server_name www.ABC.com;
}
If you have multiple virtual hosts in Nginx, each one needs to be modified.

And then it's Apache's turn to httpd.conf.
Put the original
Listen 80
Switch
Listen 127.0.0.1:80
As with Nginx, specify the IP and port that Apache occupies.
Save to exit and restart Apache to take effect.
If you have more than one virtual host on Apache. No need to modify it as if it were nginx, as long as it is 80 ports.
Such as:
Namevirtualhost *:80
ServerAdmin [email protected]
Documentroot/var/www/admin
ServerName Admin. ABC.com

(This is used to bind the background directory with admin background domain name, similar to manager.***.com)
(So, I'm afraid Apache can only access it through http://127.0.0.1:80, so it doesn't make sense to take 80 ports.) It's not as good as Apache with 8080,nginx 80. Without a serious look, the "smart" app detects that Apache is using port 8080 and will add all of the hyperlinks in the app: 8080 endings, so this is the only thing to solve. And most servers have 2 network cards, in addition to the Apache binding in the 127.0.0.1 can also bind the IP of the other net card, so the problem is solved. )
This way, Nginx and Apache will only occupy the designated IP port 80, will not conflict.
Just adjust the parameters of the Nginx proxy.
"Smart" application problems can be solved.

Nginx + Apache Public 80 port configuration

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.