Best way to redirect to a different port

mkniskanen

Verified User
Joined
Sep 17, 2008
Messages
80
Location
Lieksa, Finland
Hello,

I have a customer with only port 80 open for HTTP and the company policy forbids other ports. Now I need to install Tomcat for some specific power-hungry tasks and administer the services. I would like to keep things as separate from my PHP services as possible. My idea is this:

- I create a subdomain tomcat.mycustomer.com which should be internally redirected to port 8080 so that http://tomcat.mycustomer.com/manager, for instance, would open the Manager interface.

Now what is the best way to achieve this using DA and Apache?

Markku
 
Hello,

You might need assign a dedicated IP for that user. Then you might want to use apache's mod_proxy or do forwarding with iptables.
 
You might need assign a dedicated IP for that user. Then you might want to use apache's mod_proxy or do forwarding with iptables.

That's a an absolute no-go as it is even more difficult to get an IP address than have the company open another port. I remember doing something like about five years ago but cannot remember how I did idt.

I do not think that assigning an IP address is necessary. I believe mod_proxy should do it but how to combine it to DA the way it won't break anything?

Markku
 
Thanks, that was pretty much what I was looking for. I'll test that later this week!

And tested. That might work provided the instructions were correct. The "Loadmodule/Addmodule" part only produces errors in "httpd configtest" and I had no idea whether mod_proxy needed to be added in the conf file when it is compiled/linked into the httpd binary.

Well, no changes to main httpd.conf were necessary in Apache 2. So that should be corrected in the instructions. Moreover, the instructions did not help at all in getting things done the DirectAdmin way.

I added this manually to my customer's httpd.conf file:

Code:
<VirtualHost 123.321.231.123:80>
        ServerName tomcat.mycustomer.com
        ProxyRequests Off
        ProxyPass / http://localhost:8080/
        ProxyPassReverse / http://localhost:8080/
</VirtualHost>

and it worked. HOWEVER: I still have no idea how to administer the DirectAdmin templates or other stuff to make it possible to add this functionality to existing domains (have not tested with new ones). It may well be that there is no way to do it. I wonder if DirectAdmin will write over my manual changes at some point? I suppose that will take place when I add another subdomain to my customer's site, right?

How can I prevent that from happening?

Markku
 
Last edited:
To keep DirectAdmin from overwriting the file, chattr it immutable.

To change the template first move it to the templates/custom directory, then edit it there.

Jeff
 
Back
Top