-4

I'm using glassfish 4.1 server with port 8080.

my apps can access by hit localhost:8080 or using my_ip_address:8080.

now, I want access my apps only with ip address without entry the port, say my ip is 10.1.2.133, so when I hit 10.1.2.133 it's go to my apps. how to do it?

I've tried changing the port to 80 and it worked so well. but I still want to use port 8080 instead 80.

4 Answers4

3

I've tried changing the port to 80 and it worked so well. but I still want to use port 8080 instead 80.

Port 80 is the only default port that web browsers understand for the HTTP protocol.

If you want to use a different port (8080) for your server, you must either:

  • use port 8080 in the URL
  • set up another server on port 80 that will either redirect requests to port 8080, or reverse proxy the requests to port 8080.

Redirection works by having the server on port 80 send HTTP 3xx responses that tell user's the browser to resend the request to the URL for the port 8080 server.

Reverse proxying works by the server on port 80, sending the request to the port 8080 server itself, and then relaying the response.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
1

You could consider using a reverse proxy like apache httpd or HAProxy in front your application. Configure them to listen to port 80 and redirect requests based on the context to your application at 8080

Take a look at:: https://www.digitalocean.com/community/tutorials/how-to-use-apache-http-server-as-reverse-proxy-using-mod_proxy-extension

https://github.com/foosel/OctoPrint/wiki/Reverse-proxy-configuration-examples

https://dzone.com/articles/how-to-configure-ha-proxy-as-a-proxy-and-loadbalan

0

The default Http port is 80, and therefore if your app run at 80 you can omit it, in other cases you must specify the port. Else you must have a Proxy server listen at 80 and re-direct it to the required server based on context( read path ) or some-other information.

Antho Christen
  • 1,369
  • 1
  • 10
  • 21
0

You can run another server that points to your server on 8080. Your other server would then be running on port 80 as this is the default port.

Config on Apache would be something like this:

<VirtualHost *:80>
    ServerName sample.com

    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>

    ProxyRequests Off
    ProxyPreserveHost On
    ProxyPass / http://YOUR_IP_HERE:8080/
    ProxyPassReverse / http://YOUR_IP_HERE:8080/
    RewriteEngine On

    <!--other config here-->
</VirtualHost>
Ivonet
  • 2,492
  • 2
  • 15
  • 28