loonis
loonis

Reputation: 1487

Apache in front of Jboss url problems

I am having some problems setting up an Apache Web Server in front of Jboss.

I rent a vps with apache and jboss running up and working fine separately.

Jboss is working fine when I want to acess my app through http://myVpsUrl.com:8080/myApp/

I am trying to redirect http://myUrl.com to my jboss app.

In Apache conf file I set :

<VirtualHost *:80>
    ServerName myUrl.com
    ServerAlias myUrl.com

    ProxyPass / http://localhost:8080/context/
    ProxyPassReverse /  http://localhost:8080/context/

    ProxyPassReverseCookiePath / /
    ProxyRequests On

</VirtualHost>

When I am going to myUrl.com I can reach the web app homepage but :

My style and images are located in

http://myVpsUrl:8080/context/css/icons/devices-14-20.png
http://myVpsUrl:8080/context/javascript/util.js
http://myVpsUrl:8080/context/images/*
etc...

I tried to add

ProxyPreserveHost On

But I'm getting an error :

The page isn't redirecting properly or Infinite redirection

I am stuck with this error since a week, any help would be sincerely appreciated.

Thank you.

Upvotes: 1

Views: 5253

Answers (2)

loonis
loonis

Reputation: 1487

I finally find how to make it work.

1- Create a virtual-server in jboss

jboss-as-7.1.1.Final/standalone/configuration/standalone.xml

<virtual-server name="myVirtualServerName" default-web-module="nameOfWarFile">
   <alias name="myurl.com"/>
</virtual-server>

2- Configure jboss-web.xml

<jboss-web>
    <virtual-host>myVirtualServerName< /virtual-host> 
</jboss-web>

3- Restart Jboss and Deploy you app

=> You should be able to access your app via myurl.com:8080

4- Make a redirection from port 80 to 8080 on apache

<VirtualHost *:80>
   ServerName myurl.com
   ServerAlias www.myurl.com myurl.com

   ProxyPass / http://myurl.com:8080/
   ProxyPassReverse /  http://myurl:8080/
</VirtualHost>

5- Edit your host file (/etc/host) and add this line

127.0.0.1 myurl.com

6- Restart apache, you should be able to access your jboss via myurl.com

Upvotes: 2

scantero
scantero

Reputation: 11

you could try use the rewrite engine.

Try this:

<VirtualHost *:80>
    ServerName myUrl.com
    ProxyRequests Off
    ProxyPreserveHost On

    ProxyPass /  http://localhost:8080/context/
    ProxyPassReverse /  http://localhost:8080/context/

    RewriteEngine   On
    RewriteCond     %{THE_REQUEST}  /context/
    RewriteRule     ^/context/(.*)$ /$1 [PT]

</VirtualHost>

Upvotes: 1

Related Questions