Apache Virtual Host + reverse proxy in Ubuntu

Source: Internet
Author: User
A reverse proxy is a proxy server that allows Internet users to access the server 192.168.0.4 on the internal network. It can be understood that there are two NICs, one is a public ip address, one is two services on two servers inside and outside the 192.168.0.4 proxy, respectively running on port 9000 and port 81 01) install Apache2: sudoapt-getinstallapache2 & nbs

Reverse Proxy is a proxy server that allows Internet users to access servers on the internal network.

192.168.0.4 contains two NICs, one is a public ip address and the other is 192.168.0.4.

Two services on two servers inside and outside the proxy are running on port 9000 and port 81 respectively.

01) install Apache2:
Sudo apt-get install apache2
Test Access: 192.168.0.4

02) restart the server:
Sudo/etc/init. d/apache2 restart

03) virtual host + reverse proxy configuration:

Objective: To use the ip address 192.168.0.4 of the server where apache2 is installed as the proxy to run the tomcat server on 192.168.0.15: 9000
Prerequisites:
Apache2 is installed on 192.168.0.4 and can be accessed normally.
192.168.0.15: 9000 can also be accessed normally

Enable these modules
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.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

Enable module sudo a2enmod
Disable the sudo a2dismod Module

The commands of the above startup modules are as follows:
Sudo a2enmod proxy
Sudo a2enmod proxy_ajp
Sudo a2enmod proxy_balancer
And so on.

Create a linuxidc file in the/etc/apache2/sites-available/directory.


ServerName www.linuxidc.com
ServerAlias linuxidc.com
ProxyPreserveHost On
ProxyRequests Off

Order deny, allow
Allow from all

ProxyPass/http: // 192.168.0.15: 9000/
ProxyPassReverse/http: // 192.168.0.15: 9000/


Then enable the site
Sudo a2ensite linuxidc
Service apache2 reload

Create a file 88181 in the/etc/apache2/sites-available/directory.


ServerName www.88181.com
ServerAlias 88181.com
ProxyPreserveHost On
ProxyRequests Off

Order deny, allow
Allow from all

ProxyPass/http: // 192.168.0.11: 81/
ProxyPassReverse/http: // 192.168.0.11: 81/

Then enable the site
Sudo a2ensite 88181
Service apache2 reload

Modify C: \ WINDOWS \ system32 \ drivers \ etc \ hosts to test
192.168.0.4 linuxidc.com
192.168.0.4 88181.com

Close a Virtual Site
Sudo a2dissite linuxidc
Sudo a2dissite 88181

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.