How to redirect http and ssh to other vms based on subdomain? - traefik

I have several subdomains:
server1.domain.com ----> VM1
server2.domain.com ----> VM2
server3.domain.com ----> VM3
I would like to use traefik in order to create a transparent proxy so that when a HTTP request arrives on the server where traefik is installed, it is redirected to the corresponding VM. I would like to do the same to SSH traffic.
VM's are containers (LXC) and the virtualization management software is ProxMox.
Could someone kindly help me?

Related

How to forward HTTP/HTTPS traffic through 1 server in DMZ

I would like to send "sub-domain" traffice through 1 DMZ in my network.
I have 1 fixed IP and send my domain requests to my server through my network. ie www.example.com goes to my x.x.x.x fixed ip and ends up in my home server 192.168.1.43. Now because that server (debian 10) is the only server in the DMZ i would like to forward server requests from there to an other server in my network ie 192.168.1.39. So in the dns I would still send traffic from the internet server2.example.com towards 192.168.1.43 but from there would like to send it on to 192.168.1.39
Does anyone have tips on the virtual hosts, or proxy settings in the apache2 configs?
Thanks!
I think you are describing a reverse-proxy set up. Take a look at this guide for Apache https://httpd.apache.org/docs/2.4/howto/reverse_proxy.html
Nginx and HA Proxy are popular alternatives to Apache for this.

Why does the address get redirected to port 8080 instead of port 80?

I am trying to configure the apache load balancer on the docker container with enabled exposing port 80:80. Even load balancer configuration has been updated in load balancer config file with proper ips. Since the whole setup is working in same subnet they all are connected to each other. I am using wordpress image for web server , MySQL image for db and centos image for load balancer,even the firewall rule to masquerade has been done and port to enabled...Pls help
My loadbalancer config file
docker ps command
Error ...Why is it going to port 8080 even though I have configured 80 in loadbalancer file
As I can see here, you are trying to access 172.17.0.4:8080 on the browser. And IP 172.17.0.4 corresponds to the container wpos2. Now since you had not exposed the port 8080 of this container so the request is not being served from the browser.
Instead, you should try accessing the load balancer container lb1 using the public IP of your host machine.
Try this: <HOST_IP>:80
This will hit your load balancer and from there the request will be redirected to one of the two servers: wpos or wpos2 and you should probably get your request served.

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 (e.g 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.

Run apache in both host machine and docker container on 80 port

I need to setup something like automated server setup using docker. Now server machine should support both docker or normal setups. So I need to setup apache web server on both docker container and host machine on 80 port. Like
Host Machine : application1.serverhost.com
Docker Machine : application2.serverdocker.com
But Docker will not utilize 80 port as it is already bind on host machine apache. While I am thinking of use reverse proxy on host machine with apache like
Proxy Setting -> 172.17.0.2:8080
while on browser connect to proxy application2.serverdocker.com on 80 port. IP -> 172.17.0.2 is docker container IP which I am thinking to get from docker inspect.
But if any other way to handle this in docker itself where I can ignore reverse proxy on host machine. And call both application1.serverhost.com and application2.serverdocker.com from browser without appending port.
EDIT : One big issue using reverse proxy is that whenever I need to add another docker on same server I need to add also proxy for that new IP too as that would also running docker apache on other port like 8081 than Host port:80 and first docker's port:8080. In other words lot of reverse proxy settings and ports in case of lot of docker instances.
If you are using a reverse proxy, (like an NGiNX), that means both your Apache servers must run on ports different from 80.
Only your NGiNX would run (on host directly for instance) on port 80, and would redirect to localhost_apache1:xxx and 172.17.0.2_apache2:yyy.
From the user perspective, both Apache would be seen "as if" they were running on port 80 themselves.

DNS problem - dig resolves but curl cannot connect to host

I have recently created a Rackspace cloud server instance using CentOS 5.5. I have used yum to install the "Web Server" group (it includes Apache, etc.), added www.booztrakr.com as the ServerName in httpd.conf, made sure iptables allows on port 80. I had registered this domain with Go-Daddy and changed their name servers to the Rackspace name servers on their site. I added "A" and CNAME records to the Rackspace name servers. httpd has been started. When I use curl on the server I can get the Apache landing page. When I dig www.booztrakr.com from a remote machine(over the internet) the answer section returns:
www.booztrakr.com. 300 IN CNAME booztrakr.com.
booztrakr.com. 300 IN A 184.106.216.156
When I try a browser or curl, it can't connect:
curl -G www.booztrakr.com
curl: (7) couldn't connect to host
I know this has got to be pretty basic and config related but I'll be dammed if I can see it. Any help would be appreciated. Thanks.
If dig resolves, this just means the DNS server returns the right values. It will even work if the IP doesn't exists.
If a HTTP connecting to the server fails, this is a configuration problem.
The server responds to ICMP requests, so it's not a routing problem.
When I use curl on the server I can get the Apache landing page
Your webserver is running, but you just can't reach it from outside. This is the problem. What does iptables --list outputs?