Forum Moderators: phranque

Message Too Old, No Replies

Rewrite question

I'm a complete noob when it comes to apache configurations

         

Wesgro

6:54 pm on Aug 27, 2008 (gmt 0)

10+ Year Member



So I have this problem.

We have a website that's running a java application (on an enhydra Java application server, not through Apache. This cannot be changed). This Java app runs on a separate port from Apache (port 81), and is only accessible through its IP address.
We have dedicated hosting

What I want to do is have a folder or sub domain on our main domain rewrite to the java applications address..

So http://example.com/javaapp really points to 111.22.33.44:81..
Is this possible through .htaccess? Or do I need to change something in the Apache configuration?

Any help would be greatly appreciated.

Thanks

[edited by: jdMorgan at 3:58 pm (utc) on Aug. 28, 2008]
[edit reason] example.com & hosting specifics [/edit]

jdMorgan

3:59 pm on Aug 28, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is normally done by setting up a reverse proxy based on a <Directory> container. See the Apache mod_proxy documentation.

For special cases, you can also make use of the [P] flag in Apache mod_rewrite.

Jim

Wesgro

5:25 pm on Aug 28, 2008 (gmt 0)

10+ Year Member



Can mod_proxy be done through htaccess?

jdMorgan

5:34 pm on Aug 28, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Probably not sufficient for your needs. Have a read of the mod_proxy documentation, and pay attention to the ProxyPassReverse section.

Setting up an application server is not a 'basic' project -- Expect to spend a few days with the documentation.

Jim

Wesgro

11:40 pm on Aug 28, 2008 (gmt 0)

10+ Year Member



Ok so I've setup modproxy on my server and added the following to the httpd.conf

<IfModule mod_proxy.c>
ProxyRequests On
ProxyPreserveHost On

ProxyStatus On
<Location /status>
SetHandler server-status

Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Location>
ProxyPassReverse /intranet [localhost:81...]
ProxyPass /intranet [localhost:81...]
</IfModule>

Now it forwards from http://example.com/intranet to http://example.com:81

However I want the address bar to just stay at http://example.com/intranet

What am I doing wrong?

jdMorgan

12:13 am on Aug 29, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You only need a reverse proxy, as noted in my initial post. Opening a forward proxy is not needed for an application server, and is dangerous; *anyone* can use your server as a forward proxy, unless you take steps to lock it down.

I don't think that would cause the address bar to change, so look for mod_alias, mod_rewrite, or scripted redirects -- Only a redirect is going to send a response to the browser and make it change its address bar.

Jim

Wesgro

12:24 am on Aug 29, 2008 (gmt 0)

10+ Year Member



I've changed it to:

<IfModule mod_proxy.c>
ProxyRequests On
ProxyPreserveHost On

ProxyStatus On
<Location /intranet>
SetHandler server-status
Order Deny,Allow
Deny from none
Allow from all
</Location>
ProxyPassReverse /intranet [localhost:81...]

</IfModule>

Now when I go to example.com/intranet it jumps to an Apache status page?

Wesgro

3:34 am on Aug 29, 2008 (gmt 0)

10+ Year Member



I figured out why I was getting Apache status (duh, setHandler server-status)
My new directives are:
#
#Proxy server directives.
#
<IfModule mod_proxy.c>
ProxyRequests Off
ProxyPreserveHost On

ProxyStatus On
<Proxy *>
Order Deny,Allow
Allow from all
</Proxy>

ProxyPassReverse / [localhost:81...]
<Location /intranet>
Order allow,deny
Allow from all
</Location>

However when I go to example.com/intranet I get:

Not Found
The requested document was not found on this server.