January 9th, 2012 by Lincoln Baxter III

JBoss Application Server 7 on Port 80 with Apache HTTPd ProxyPass

It’s quite simple really. All you need to do is install Apache HTTPd, then set make sure you have a few modules installed and set up: Instructions below are for Ubuntu, Fedora, RHEL, or other Linux distributions. So what are you waiting for? Let’s get our JBoss / Apache love on.

The 9 steps to proxy success!

  1. Install Apache2.
  2. sudo a2enmod proxy
  3. sudo a2enmod proxy_http
  4. sudo a2enmod vhost_alias
  5. sudo a2dissite default (only if you are not using this site, or haven’t made changes to it)
  6. Create a file called jboss-as in /etc/apache2/sites-available:

    <VirtualHost *:80>    ServerAdmin admin@site.com    ServerName site.com    ProxyRequests Off    <Proxy *>       Order deny,allow       Allow from all    </Proxy>    ProxyPreserveHost on    ProxyPass / http://localhost:8080/ </VirtualHost>
  7. sudo a2ensite jboss-as
  8. Make sure your JBoss AS 7 instance is running on port 8080, and is accepting connections from localhost.
  9. sudo /etc/init.d/apache2 restart -or- service apache2 restart

In summary

That’s it! Your JBoss AS 7 instance should now be available on Port 80. You can, of course, make further customizations to this configuration; it is merely a bare minimal example in order to get up and running. As always, I hope this has been helpful. Please let me know how it works for you!
Lincoln Baxter, III

About the author:

Lincoln Baxter, III is the Chief Editor of Red Hat Developers, and has worked extensively on JBoss open-source projects; most notably as creator & project lead of JBoss Forge, author of Errai UI, and Project Lead of JBoss Windup. This content represents his personal opinions, not those of his employer.

He is a founder of OCPsoft, the author of PrettyFaces and Rewrite, the leading URL-rewriting extensions for Servlet, Java EE, and Java web frameworks; he is also the author of PrettyTime, social-style date and timestamp formatting for Java. When he is not swimming, running, or playing competitive Magic: The Gathering, Lincoln is focused on promoting open-source software and making technology more accessible for everyone.

Posted in JBoss, OpenSource

9 Comments

  1. Markus says:

    Hi Lincoln,

    thanks for the post. What exactly are you doing with step 7?
    If you are trying to run JBoss with an unprivileged user, you should (and can!) skip this step.

    Thanks,
    M

    1. Hey Markus! Step seven enables the Apache configuration that we just created. I don’t think it would work without this step! How would you get around it?

  2. Fabio says:

    Hi Lincoln,
    thanks for the post!
    Your instruction works well on Ubuntu/Debian but for Fedora/CentOS/RHEL the procedure is sliglty different because you don’t have de command a2enmod and you don’t have the directory /etc/apache2/sites-available.
    On Fedora/Centos/RHEL you have to copy the file jboss-as under /etc/httpd/conf.d and restart apache

    Cheers!

  3. gUNASEKHAR says:

    Can You Please help me in implementing Https in Jboss 7

  4. Jon says:

    This is a great way to expose any appserver on port 80.
    I usually also use ProxyPassReverse and ProxyPassReverseCookiePath, any reason you omitted these?

    1. Hey Jon! Good to hear from yuo 🙂 I hope all is well. I didn’t omit them for any other reason than I didn’t know about them. Care to explain?

      1. Jon says:

        All is well here 🙂

        I’m no Apache expert, but as far as I know, ProxyPassReverse should be added to make sure http redirects are rewritten correctly. But I know there is discussions about using it (hence my asking you).

        The ProxyPassReverseCookiePath rewrites cookie paths, i.e you have a webapp at /my-app but run Apache on / , the browser will not accept your cookies because they are only valid for /my-app. I see in your example you are just using / so there would be no need for this here 🙂

  5. Gunasekhar says:

    JBoss Application Server 7 on Port 443 with Apache HTTPd ProxyPass

  6. Arun says:

    I’m new to infra & jboss configuration. I have been trying above steps on Ubuntu. Im facing issue from step 5.
    step5: error: site default does not exist.
    step6: created jboss-as file as mentioned(without changing anything)
    step7: error: site jboss-as does not exist.
    step8: error:AH00558: apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1. Set the ‘ServerName’ directive globally to suppress this message

Leave a Comment




Please note: In order to submit code or special characters, wrap it in

[code lang="xml"][/code]
(for your language) - or your tags will be eaten.

Please note: Comment moderation is enabled and may delay your comment from appearing. There is no need to resubmit your comment.