LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Apache - redirect to internal server (https://www.linuxquestions.org/questions/linux-server-73/apache-redirect-to-internal-server-919321/)

ScorchPipe 12-18-2011 08:06 AM

Apache - redirect to internal server
 
Hi

I have a web server running Apache. Here I have a website with some personal, useful stuff like ruTorrent, system information, webmin, Motion etc

Some time ago I installed Op5 on a different machine. Op5 has it's own web interface and database.

I want to be able to access this web interface through a <a href> link on my usual website. Maybe like a location in httpd.conf where mywebsite.com/op5 will put me through to the Op5 machine.

Both servers are behind a router and I still want to use standard ports.

Is there a way to solve this?

CentOS is running on both machines btw

edit:
Ofc, the best would be if it still looks like the user is on mywebsite.com/op5 in the adress field

bathory 12-18-2011 09:29 AM

Hi,

You can use apache as a reverse proxy:
Code:

ProxyRequests Off
ProxyPass /op5 http://x.x.x.x
ProxyPassReverse /op5 http://x.x.x.x

where x.x.x.x is the internal IP of your box running that Op5

Regards

ScorchPipe 12-18-2011 11:23 AM

Quote:

Originally Posted by bathory (Post 4552973)
Hi,

You can use apache as a reverse proxy:
Code:

ProxyRequests Off
ProxyPass /op5 http://x.x.x.x
ProxyPassReverse /op5 http://x.x.x.x

where x.x.x.x is the internal IP of your box running that Op5

Regards

Hi and thanks for your response.

I added this to httpd.conf and restarted httpd. Now it works when I'm on my LAN, but not from the outside.
Gets "connection has timed out" because it's trying to contact my internal IP

bmarx 12-18-2011 11:41 AM

What does the link inside <A HREF=""> look like? It should be referencing the public server, not the internal host behind the proxy.

ScorchPipe 12-18-2011 12:59 PM

Quote:

Originally Posted by bmarx (Post 4553029)
What does the link inside <A HREF=""> look like? It should be referencing the public server, not the internal host behind the proxy.

It doesn't exists yet. I just went to mywebsite.com/op5 to test bathory's method

bathory 12-18-2011 03:23 PM

Quote:

Now it works when I'm on my LAN, but not from the outside.
Gets "connection has timed out" because it's trying to contact my internal IP
Doesn't make sense. If the frontend apache can connect to the backend webserver with its internal IP, it should work the same either from LAN and from the internet.

ScorchPipe 12-18-2011 03:36 PM

Quote:

Originally Posted by bathory (Post 4553155)
Doesn't make sense. If the frontend apache can connect to the backend webserver with its internal IP, it should work the same either from LAN and from the internet.

The connection between them is just fine. Also tried without any firewalls running.

Same problem:
"The connection has timed out
The server at 192.168.0.198 is taking too long to respond."

bathory 12-18-2011 04:23 PM

Quote:

"The connection has timed out
The server at 192.168.0.198 is taking too long to respond."
I don't know what to tell
If the frontend can connect to the backend (I guess it's 192.168.0.198), then there should be no problem. Maybe your router is doing something nasty.
Anyway you can add the following before the other proxy directives, to see if they help
Code:

<Proxy *>
    Order deny,allow
    Allow from all
</Proxy>
ProxyPreserveHost On
ProxyTimeout 300
...


ScorchPipe 12-18-2011 04:57 PM

Quote:

Originally Posted by bathory (Post 4553199)
I don't know what to tell
If the frontend can connect to the backend (I guess it's 192.168.0.198), then there should be no problem. Maybe your router is doing something nasty.
Anyway you can add the following before the other proxy directives, to see if they help
Code:

<Proxy *>
    Order deny,allow
    Allow from all
</Proxy>
ProxyPreserveHost On
ProxyTimeout 300
...



Tried it. Now it says
"The server at mywebsite.com is taking too long to respond"
from both inside and outside.

I will look into the router, but I don't think I will find anything there

Thanks for your help anyway

bathory 12-19-2011 02:08 AM

Quote:

Tried it. Now it says
"The server at mywebsite.com is taking too long to respond"
from both inside and outside.
I guess it's the timeout that is too big and your browser times out first.
I can't think of anything else about the initial problem. If the reverse proxy works through your LAN, it should work from the outside too.
It's maybe your router, or the backend application (op5) needs some special settings to work behind a reverse proxy


All times are GMT -5. The time now is 09:35 AM.