简体   繁体   中英

Setting firewall rules to enabling running Apache2HttpServer and ApacheTomcat 9 on the same machine with two different hostname/ip:port

I have a Virtual Machine Linux Debian 10, with two Host-Only Network interfaces actived respectvely 192.168.56.10 and 192.168.56.15 with static ip address. Apache Tomcat 9 is installed and Apache2 Http Server is installed too. My purpose is that Apache Tomcat 9 must run on 192.168.56.15:8080 , while Apache2 Http Server must run on 192.168.56.10:80 . The /etc/hosts file in my Linux is:

#

192.168.56.10 www.example.com

192.168.56.15 openam.example.com

#

The C:\\Windows\\System32\\drivers\\etc\\hosts is the same.

In short I'm trying to setup a small development enviroment for Identity and Access Managment using the Forgerock's AM solution. That software has to be deployed as a .war file (openam.war) in Tomcat /webapps and it will be mapped as openam.example.com , and I want this service run on 192.168.56.15:8080/openam ;

So my problem is that I want two different services responding two different interfaces but running on the same Virtual machine. I want that only if i type 192.168.56.15:8080 or openam.example.com:8080 I recive a respond from Tomcat, but if I type 192.168.56.15:80 or openam.example.com:80 Apache Http Server doesn't have to respond. Apache Http Server have to respond only on 192.168.56.10:80 or www.example.com .

In this way I can have like two different machines one with the web server and one with the application server, responding on two different IP addresses and hostname, but running on the same machine.

Thanks for help!

You could have 2 IPs but what's the point in doing so?

I find it rather pointless to have 2 separate IPs for 2 different services on the same machine (eg tomcat on 1 / HTTP server on the other) for a development environment inside a VM. Port handling will be handled by the operating system itself and route the request to the open port.

Keep in mind that browsers will try to connect http:// calls on port 80 by default - so unless you type 8080 into the URL the browser it is just going to use port 80.

If you do not want calls to openam.example.com to come in on port 80, the simplest way round it is to use a htaccess rule that implements a rewrite for any request that contains openam.example.com (or just anything in a subdomain portion) on port 80 to be rewritten to the appropriate URL.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM