apache and IIS share the 80 port solution

  • 2020-05-09 19:45:42
  • OfStack

Step 1: change the default port of iis website from 80 to 8080;
Step 2: modify the httpd.conf configuration file for apache.
First of all, to enable apache to support forwarding, that is, to be the agent of iis, the agent module of apache should be enabled.
#LoadModule proxy_module modules/mod_proxy.so 
#LoadModule proxy_connect_module modules/mod_proxy_connect.so #LoadModule proxy_ftp_module modules/mod_proxy_ftp.so #LoadModule proxy_http_module modules/mod_proxy_http.so 

Then remove the "#" from the front of each line of code, and you open the apache proxy module.
Then add the following code to the httpd.conf file:
NameVirtualHost 111.111.111.111:80  
<VirtualHost *:80> 
DocumentRoot  d:/apache/www/test1 (note: c Actual local address of the station) 
ServerName www.c.com </VirtualHost> 
<VIRTUALHOST 111.111.111.111:80>
ServerName www.a.com    
    ProxyPass / http://www.a.com:8080/   
    ProxyPassReverse / http://www.a.com:8080/ </VIRTUALHOST> 
<VIRTUALHOST 111.111.111.111:80>
ServerName www.b.com    
    ProxyPass / http://www.b.com:8080/   
    ProxyPassReverse / http://www.b.com:8080/
</VIRTUALHOST> 

In the code above, 111.111.111.111 represents the IP address of the server. In practice, you should use the real address of your own server.
Step 3: restart the apache service
This step is essential, otherwise the Settings we did in the first two steps will not take effect. After completing the above three steps, we can now visit www.a.com, www.b.com, www.c.com, which means that we have successfully set up apache and IIS to share port 80

Related articles: