0

I have a RichFaces WAR file that deploys itself to http://mytestserver:8080/mywarapp/index.jsp. I deploy it on the Wildfly Application Server.

Now I would like to access the WAR file not through this long http-address, but through the main server address: http://mytestserver/

How would I have to do that?

Pokechu22
  • 4,984
  • 9
  • 37
  • 62
Socrates
  • 8,724
  • 25
  • 66
  • 113

1 Answers1

1

You should change context path of your application.

To do this you need to create file jboss-web.xml and place it in WEB-INF directory. jboss-web.xml should contain:

<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
    <context-root>/</context-root>
</jboss-web>

If you want to change port of your application from 8080 to 80 you can do this in few ways.
1) [not recommended] change port in your standalone/domain.xml from 8080 to 80 and run wildfly as a root/administrator
2) run nginx/apache or any other webserver and create there proxy redirect eg. in nginx you need to add to your configuration file something like this proxy_pass http://mytestserver:8080/; (if you didn't add jboss-web.xml you need append here mywarapp to this URL ) and your application will be available via URL http://mytestserver/

Krzysztof Miksa
  • 1,519
  • 1
  • 16
  • 23
  • 1
    Why do you say that 1) is not recommended? It looks cleaner to me than to combine 2 running servers (Wildfly and Apache) on one system just for one application. – Socrates Sep 10 '14 at 13:20
  • I don't recommend 1) solution for production use. In my opinion on production is better to keep AS behind webserver for security purpose – Krzysztof Miksa Sep 10 '14 at 14:57
  • 1
    What is the reason? Is Wildfly unsafe? Is Wildfly not meant to be the main server? – Socrates Sep 13 '14 at 08:58
  • There is no any real reason. I think multilayered architecture is a good pattern. I didn't heard about any serious vulnerability in security in wildfly so I think it is safe enough. I stared with JBoss 4 so there wasn't something like 'domain mode' and there was no possibility to create rewrite rules so this became for me habit to keep application servers behind webservers and loadbalanders. For me it is much more easier to write and maintain URL rewrite rules eg. in nginx than in undertow subsystem especially when I have to maintain many applications and many domains on one server – Krzysztof Miksa Sep 14 '14 at 18:00
  • 1
    Sorry, I have to reopen this. I finally found the time to check this again. But having included the `jboss-web.xhml` I now have changed the message from `Forbidden` to `Not Found`. What place does Wildfly exactly look for now having the jboss-web.xml? I have an `Index.xhmtl` as main page. Changed it as a test to `index.xhtml`, but didn't change a thing. – Socrates Nov 05 '14 at 12:06
  • Hi @Krzysztof Miksa ! I went through this again and must say, that building this up in layers for production makes sense. Now, speaking of Apache, could you point me in a direction on how to do the proxy_pass? I have never played around with that and would like to test it. How would I have to do that? – Socrates Dec 02 '14 at 12:24
  • email me or skype it will be faster way to explain than in commments – Krzysztof Miksa Dec 02 '14 at 19:02
  • Hi @Krzysztof Miksa ! Thanks for your Skype offer. Though I am in Japan, so the time difference may be disturbing. Concerning email, I would probably not ask anything different than whether you know a quick How To or a little Manual online? This way I may take my time and study myself through. – Socrates Dec 04 '14 at 11:25