Forward Apache Server to Proxmox Web Gui - apache

So, I'm pretty new to apache and I'm having some issues finding a solution to my answer.
I have a domain name abcdefg.com (for example) and I have a public facing Fedora apache webserver on my home network at 192.168.10.10. I then have another machine that is a proxmox VE server at 192.168.10.20.
I know I can forward ports and just type [https://abcdefg.com:8006] to get to my proxmox server, but I want to be able to go to abcdefg.com/proxmox and it then somehow make a call to [https://192.168.10.20:8006] internally (https is required).
Can anyone point me in the right direction? I don't need to be spoonfed, I'm just not sure where to start looking. I've already figured out how to use the "Location" tags but its not working for this, seems to be a bit more involved.
--Cheers

You need to run a reverse proxy server, which Apache can do with a few extra mods. This will listen on a specific port (Let's say port 444 in your case) and send requests to whatever IP and port you specify behind the scenes.
See the following link for how to reverse proxy a site: Simple Apache reverse proxy example
Simply change the mywebsite.jamescoyle.net references to point to your internal proxmox box on port 8006 - eg.
ProxyPass https://192.168.10.20:8006/
ProxyPassReverse https://192.168.10.20:8006/

Related

If two Apache HTTP servers are installed in RedHat, how to make them not disturbing each other

I have already installed an Apache HTTP server in my RedHat system, now I need to install a Bitnami application package which contains another Apache. So I am wondering how to make them not disturbing each other?
I guess I need to configure different ports for the two HTTP server. But what if one has 8080 and another has 9090, will we visit http://[ServerName]:8080/something.html and http://[ServerName]:9090/something.html? I think this way is quite inconvenient. Am I wrong or any better idea?
My advice would be to do something like this.
Have one Apache instance listen in port 80 and the other one in port 8080 for example. The Apache instance that listens in port 80 can act as a proxy to the other Apache (port 8080) using the ProxyPass and ProxyPassReverse directives.
https://httpd.apache.org/docs/2.4/mod/mod_proxy.html
You would need to define prefixes or virtual hosts and inside them add ProxyPass directives.
I don't know to what kind of user those applications are targeted to but the usual end-user is not used to enter ports when browsing the web.
If you like to use the ports, go for it, but I would recommend using Name-based Virtual Host
so you could use different domains or subdomains to each application.
In addition to the example provided by the docs (in where they just point to different folders) in this digitalocean page they document how to make redirects to different urls.
I completely agree with EndermanAPM that usual end-user is not used to enter ports when browsing the web. Therefore, I would only allow port 80 to be accessed by the end-users.
Additional to the current solutions I see another one:
avoid messing up the settings of the Apache servers in order to not end-up with some malfunctions of your websites
leave the Apache servers listen on their designated ports (8080 respectively 9090)
install a dedicated proxy in front of the Apache servers. The proxy would listen on port 80 and would define redirect rules that would parse the request and would redirect it to the proper Apache server. (see the attached picture)
I recommend you HA Proxy. It is a very fast and reliable http and tcp proxy. I've been using it in production for years, in front of application servers, web servers and even database servers. Once you get used with its syntax, it is pretty easy to use.
I am aware that introducing a new component into the equation might add another source of potential issues. But I think that the architecture is cleaner. Besides, the two Apache servers will not be disturbing each other as you requested. You can shut down any one of the two and the other one would properly work further.

Forward an address on my server to a specific port

I'm currently in the process of setting up a media server for my dorm floor.
I installed Subsonic, which runs on port 4040 of my server at [domain].
Right now to access the media on subsonic, you have to go to [domain]:4040
Is there a way to make an address on my server can be used to access this port, for example: [domain]/media is equivalent to [domain]:4040
My server is running Ubuntu Server 11.10, with Apache.
Thanks.
Sure. Apache's mod_proxy will do exactly what you want -- take a request coming in on one port and forward it to another. Something as simple as the following might do the trick:
<Location /media/>
ProxyPass http://localhost:4040
ProxyPassReverse http://localhost:4040
</Location>
You can read more in the mod_proxy documentation.
I don't know what listen to your 4040 port, the streaming server or a web interface to the server?
If it is a web interface, mod_proxy will do the trick like larsks said, however it does not work for every TCP protocol (list of supported protocol in documentation link provided by larsks).
If it does not work the only way is to create a subdomain that redirect to a different IP that is owned by the server and use a firewall rule to redirect traffic going to this ip to 4040 port.
Regards

Dynamic DNS and reverse proxies: Can this be done?

Here is my situation. I have a LAN at home, behind a regular router.
I have my server on 192.168.0.9, on this I have bind9 running, apache2 on port 80. Tomcat on port 8082 and another tomcat on port 8083.
I have successfully setup bind so that when I am inside my LAN I can enter:
app1.mylan.com Apache will reverse proxy this to app1.mylan.com:8082 and it shows in the browser as app1.mylan.com
Same goes for app2. (i.e. app2.mylan.com -> app2.mylan.com)
However, my router has dynamic dns setup.
How can I reach app1.mylan.com via dynamic dns. I've tried setting up a URL redirect with my DNS provider (even enabling cloaking)
but what happens is that in the browser, the apache server tries to serve up the content as if it was on port 80, and I get a 404.
It's as if the reverse proxy is not working due to the dyn dns.
Can this be done with dynamic dns???
Many thanks,
Kevin.
Yes, it certainly can be done. But it will require a few things and your description is a bit vague so I'll give you a fairly generic answer:
For it to work, every DNS entry for your zone must be changed to point to your external (dynamically changing) IP address. So when your router gets a new external address, you'll need to have dynamic DNS change the content of your zone to reflect this. You haven't said how you're doing this, but it sounds like you have it working. But if you're just running bind on your internal LAN and only changing it there, it won't work. If you own, for example, "mylan.com" then you need to tell ".com" that your name server has changed addresses too and that the authority has moved. It is unlikely you can do that change in an automated fashion. Instead, you'll likely need an external DNS provider for "mylan.com" that you can update without changing the registered NS records for mylan.com itself.
But to make it worse, if you have your internal LAN behind a NATing router (which is why you have 192.168....) then you need to tell the NAT box to do forwarding as well. Your NAT box will need to forward everything coming in to its address on port 53 (UDP and TCP both) to your internal box for DNS, and everything to port 80 to your internal box. And possibly 8082 and 8083 as well, but if you have the proxying set up properly this shouldn't be necessary.

Ports Apache and ExpressJS

I am using Apache, which listens on port 80, expressjs and socket.io. Mainly, my question is in which port should I make expressjs to listen to so that I do not need to write the port on the url.
Let's say I want to get the id of this url:
localhost/web/:id
The problem is that if I have Apache running on port 80, then expressjs won't recognize that url, so I should write it like this [if I have app.listen(81)]:
localhost:81/web/:id
Which is actually unreal because I can't make the user to write :81
I've read something about http-node-proxy, but don't understand pretty well
Thanks!
Why do you need to run both Apache and Node?
If its a requirement, you're going to need to come up with a way to forward a particular route/path on to the particular server you're hosting resources on. This is called a reverse http proxy.
You can:
Run Apache on port 80 and forward a subset of urls onto node, which will run on a non-80 port - http://www.apachetutor.org/admin/reverseproxies
Run node on port 80 and use something like node-http-proxy to set up route forwarding - http://blog.nodejitsu.com/http-proxy-intro
Run something like ngnix as the reverse proxy, and have both apache and node on non-80 ports - http://www.ubuntugeek.com/using-nginx-as-a-reverse-proxy-to-get-the-most-out-of-your-vps.html
Or... collapse your servers and just use node. Node can do static file hosting (not super well, but that's all relative)

Apache and IIS side by side (both listening to port 80) on windows2003

What are some good ways to do this? Is it even possible to do cleanly?
Ideally I'd like to use packet headers to decide which server should handle requests. However, if there is an easier/better way let me know.
It's impossible for both servers to listen on the same port at the same IP address: since a single socket can only be opened by a single process, only the first server configured for a certain IP/port combination will successfully bind, and the second one will fail.
You will thus need a workaround to achieve what you want. Easiest is probably to run Apache on your primary IP/port combination, and have it route requests for IIS (which should be configured for a different IP and/or port) to it using mod_rewrite.
Keep in mind that the alternative IP and port IIS runs on should be reachable to the clients connecting to your server: if you only have a single IP address available, you should take care to pick an IIS port that isn't generally blocked by firewalls (8080 might be a good option, or 443, even though you're running regular HTTP and not SSL)
P.S. Also, please note that you do need to modify the IIS default configuration using httpcfg before it will allow other servers to run on port 80 on any IP address on the same server: see Micky McQuade's answer for the procedure to do that...
I found this post which suggested to have two separate IP addresses so that both could listen on port 80.
There was a caveat that you had to make a change in IIS because of socket pooling. Here are the instructions based on the link above:
Extract the httpcfg.exe utility from the support tools area on the Win2003 CD.
Stop all IIS services: net stop http /y
Have IIS listen only on the IP address I'd designated for IIS: httpcfg set iplisten -i 192.168.1.253
Make sure: httpcfg query iplisten (The IPs listed are the only IP addresses that IIS will be listening on and no other.)
Restart IIS Services: net start w3svc
Start the Apache service
For people with only one IP address and multiple sites on one server, you can configure IIS to listen on a port other than 80, e.g 8080 by setting the TCP port in the properties of each of its sites (including the default one).
In Apache, enable mod_proxy and mod_proxy_http, then add a catch-all VirtualHost (after all others) so that requests Apache isn't explicitly handling get "forwarded" on to IIS.
<VirtualHost *:80>
ServerName foo.bar
ServerAlias *
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:8080/
</VirtualHost>
Now you can have Apache serve some sites and IIS serve others, with no visible difference to the user.
Edit: your IIS sites must not include their port number in any URLs within their responses, including headers.
You need at least mod_proxy and mod_proxy_http which both are part of the distribution (yet not everytime built automatically). Then you can look here: http://httpd.apache.org/docs/2.2/mod/mod_proxy.html
Simplest config in a virtualhost context is:
ProxyPass /winapp http://127.0.0.1:8080/somedir/
ProxyPassReverse /winapp http://127.0.0.1:8080/somedir/
(Depending on your webapp, the actual config might become more sophisticated. )
That transparently redirects every request on the path winapp/ to the windows server and transfers the resulting output back to the client.
Attention: Take care of the links in the delivered pages: they aren't rewritten, so you can save yourself lotsa hassle if you generally use relative links in your app, like
<a href=../pics/mypic.jpg">
instead of the usual integration nightmare of every link being absolute:
<a href="http://myinternalhostname/somedir/crappydesign.jpg">
THE LATTER IS BAD ALMOST EVERY SINGLE TIME!
For rewriting links in pages there's mod_proxy_html (not to confuse with mod_proxy_http!) but that's another story and a cruel one as well.
Either two different IP addresses (like recommended) or one web server is reverse-proxying the other (which is listening on a port <>80).
For instance: Apache listens on port 80, IIS on port 8080. Every http request goes to Apache first (of course). You can then decide to forward every request to a particular (named virtual) domain or every request that contains a particular directory (e.g. http://www.example.com/winapp/) to the IIS.
Advantage of this concept is that you have only one server listening to the public instead of two, you are more flexible as with two distinct servers.
Drawbacks: some webapps are crappily designed and a real pain in the ass to integrate into a reverse-proxy infrastructure. A working IIS webapp is dependent on a working Apache, so we have some inter-dependencies.
I see this is quite an old post, but came across this looking for an answer for this problem. After reading some of the answers they seem very long winded, so after about 5 mins I managed to solve the problem very simply as follows:
httpd.conf for Apache leave the listen port as 80 and 'Server Name' as FQDN/IP :80.
Now for IIS go to Administrative Services > IIS Manager > 'Sites' in the Left hand nav drop down > in the right window select the top line (default web site) then bindings on the right.
Now select http > edit and change to 81 and enter your local IP for the server/pc and in domain enter either your FQDN (www.domain.com) or external IP close.
Restart both servers ensure your ports are open on both router and firewall, done.
This sounds long winded but literally took 5 mins of playing about. works perfectly.
System:
Windows 8, IIS 8, Apache 2.2
Installing Windows 10 I had this problem: apache(ipv4) and spooler service(ipv6) listening the same 80 port.
I resolved editing apache httpd.conf file changing the line
Listen 80
to
Listen 127.0.0.1:80
That's not quite true. E.g. for HTTP Windows supports URL based port sharing, allowing multiple processes to use the same IP address and Port.
You will need to use different IP addresses. The server, whether Apache or IIS, grabs the traffic based on the IP and Port, which ever they are bound to listen to. Once it starts listening, then it uses the headers, such as the server name to filter and determine what site is being accessed. You can't do it will simply changing the server name in the request