apache reverse proxy summary

Today received the task and asked to a php project (deployed on apache) and java project (deployed on tomcat) on the same server, and achieve ip domain names.

ip access

ip access much easier, as long as the success of the project start, plus ip port number can be visited, if outside the network can not access, we must consider whether or not the following reasons:

1. The server port number to the firewall stopped, the server can choose to turn off the firewall or firewall configuration inbound rule, opening the port number of items, items allowed through the firewall port numbers. (A detailed tutorial on Baidu, and simple, there is not much talked about)

2. If the server is to use a third-party server, such as Ali cloud, the port is also a problem, Ali cloud server daemon default port 80 is open, if the project uses port 8080, then to the cloud server back to Ali port 8080 open.

Domain names

In fact, domain names and IP access can also be as simple as, followed by the port number can be achieved in this domain, but nothing more unsightly! How to do that to be beautiful? 80 port number into the browser hidden by default port 80, only the domain name, in essence, or domain name plus port access. But how do the two projects?

Two projects, a clear need for two separate domain names, because the two projects on the same server, and a server corresponds to only one IP address, so the two domain names can only point to the same IP address.

This requires apache reverse proxy to achieve a specific operation, see chapter blog apache proxy phpWeb project, tomcat, iis, the common port 80
apache port 80 is responsible for monitoring, ip plus point to the corresponding port project under different domain names, you can achieve both items shared 80 ports for domain names.

Originally thought in accordance with the above blog to complete the task today, but since this is not simple php project, deployed on apache also integrates zendServer, the result of the operation to "#Include conf / extra / httpd-vhosts.conf" of "# "after the removal, apache life and death start unsuccessful, resulting in php project can not run.

Ever since, immediately after the start of the Internet to find reasons to remove "#", apache not start, find all say
httpd-vhosts.conf not caused by the configuration, but on closer inspection there are no wrong, after all, have been operating in accordance with the above blog success case, put the reason excluded. Noting also that the knowledge of this deployment is deployed on apache php project also integrates zendServer, much deliberation think it is zendServer this thing up to no good, and then find zendServer on the Internet, but did not find anything useful. And much deliberation, suddenly a flash, I do not why the new apache to reverse proxy apache php this project? Php more convinced that this project integrated zendServer the apache do not "pure", and not the original look You can not use httpd-vhosts.conf configured to do a reverse proxy, since this would allow the new to apache.

Went ahead and download the new apache, or in accordance with the above blog to configure apache, httpd-vhosts.conf make the following configuration changes

##旧apache的php项目
##旧apache的php项目域名
##旧apache的php项目访问地址
<VirtualHost *:80>
         ServerName www.bbb.com
         ProxyPass / http://localhost:90/
         ProxyPassReverse / http://localhost:90
</VirtualHost>
##tomcat
##tomcat项目域名
##tomcat项目访问地址
<VirtualHost *:80>
         ServerName www.ccc.com
         ProxyPass / http://localhost:8080/
         ProxyPassReverse / http://localhost:8080
 </VirtualHost>

The new apache listening on port 80, 90 and reverse proxy to port 8080, the old apache port to 90, tomcat 8080 port configuration is complete, restart apache two months, modify the host file, the test is successful, and finally get the task.

to sum up

Find apache reverse proxy really easy to do, open the corresponding module (that is, remove the comments section), then you can configure the look httpd-vhosts.conf, but before doing apache reverse proxy configuration, to make the following points:

1. Server firewall ports open
2. Ali cloud server open port (to use the words of the third-party server)
3. Ensure http: // localhost: 8080 / to access to the project

Published 14 original articles · won praise 6 · views 6326

Guess you like

Origin blog.csdn.net/weixin_43817709/article/details/103065722