1

I have purchased a domain name www.mydomainname.com Created a web application and deployed it on glassfish 4.1.1 on ubuntu VS. Right now I am able to access the application from browser by accessing http://my-public-ip:8080/mydomainname/index.jsp what I need is to enter mydomainname.com on a web browser and end up on my application and not on the default page at the registrars site.

I tried logging into my account at the registrar and forwarded requests to http://mydomainname.com to http://my-public-ip:8080/mydomainname/index.jsp but it still displays the ip on the address bar. How do I accomplish this?

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
    <listener>
        <description>ServletContextListener</description>
        <listener-class>com.qualebs.controller.SessionListener</listener-class>
    </listener>
    <listener>
        <description>ServletContextListener</description>
        <listener-class>com.qualebs.controller.ContextListener</listener-class>
    </listener>
    <listener>
        <description>fileupload temporary file cleaner</description>
        <listener-class>org.apache.commons.fileupload.servlet.FileCleanerCleanup</listener-class>
    </listener>
    <servlet>
        <servlet-name>ImageServlet</servlet-name>
        <servlet-class>com.qualebs.controller.ImageServlet</servlet-class>
    </servlet>
    <servlet>
        <servlet-name>AsyncServlet</servlet-name>
        <servlet-class>com.qualebs.controller.AsyncServlet</servlet-class>
    </servlet>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
    <jsp-config>

    </jsp-config>
</web-app>

willing to post any relevant code if deployment descriptor is not relevant here. thanks in advance

qualebs
  • 1,291
  • 2
  • 17
  • 34

1 Answers1

1

You can configure GlassFish to listen on port 80, so that you don't need to specify a port number, but this won't give you the most control.

What you're trying to do with your DNS is much better handled by a dedicated load balancer or proxy. There are a few available, but popular ones are apache httpd; nginx and haproxy.

Apache httpd (often just called "apache") is by far the most widely used, and therefore you will probably find much more information on how to configure it. The problem is that, because it is popular, there will also be a lot of confusing and badly explained information!

My recommendation for a solution would be to use Apache and one of two plugins called mod_jk and mod_proxy. You're running Ubuntu, so there are ppa packages available for Apache and mod_jk to make initial setup easier (mod_proxy is included by default).

You can use any Apache setup guide, because there is no configuration needed for the server side (GlassFish in this case) unless you want things like clustering, which it doesn't seem that you do.

Mike
  • 4,852
  • 1
  • 29
  • 48
  • [This blog post describes setting up a cluster with GlassFish with an Apache + mod_proxy load balancer.](http://blog.c2b2.co.uk/2013/03/creating-simple-cluster-with-glassfish.html) Note that you can ignore the clustering part, and **definitely** ignore the `jk-listener` part! It's not necessary for you, just the `proxypass` directives. – Mike Nov 18 '16 at 09:15
  • [This blog post goes over installing apache and mod_jk on Ubuntu](http://blog.c2b2.co.uk/2013/10/how-to-install-apache-and-modjk.html). – Mike Nov 18 '16 at 09:16
  • [This blog post describes configuring apache to forward to Tomcat using mod_jk](http://blog.c2b2.co.uk/2014/04/how-to-set-up-cluster-with-tomcat-8.html). It will work with GlassFish too, but you do need to enable the `jk-listener` part in GlassFish for this one! The `jvmRoute` bits aren't relevant, because they are for clustering – Mike Nov 18 '16 at 09:21
  • (I didn't add these links to the answer, because SO likes answers to stand on their own and not rely on content from off-site, so these are just offered as places to begin your search) – Mike Nov 18 '16 at 09:22
  • Hello Mike I have edited the question to reflect the problem I am experiencing trying to use apache would you kindly help me see where I am going wrong. thanks in advance – qualebs Dec 04 '16 at 11:33
  • If you need to ask a new, or follow-up question, it is better to create a new one and link to the original. My answer here was correct for the question as it was asked, but is now invalid. This would make it difficult for future users to understand the question and answer. Please copy/paste your edits into a new question and then revert the edit to this one. – Mike Dec 04 '16 at 11:38
  • Feel free to add a link to it here and I will try to answer your question there – Mike Dec 04 '16 at 11:38
  • 1
    Sorry mate just seen the mistake I did. I have rolled back the edits posting new question now – qualebs Dec 04 '16 at 20:10
  • http://stackoverflow.com/questions/40963322/how-to-setup-glassfish-4-1-1-behind-apache-on-ubuntu-16-04-server this is the new question. – qualebs Dec 04 '16 at 20:34