I have a domain like www.example.com
, I'm using Glassfish
, which hosts my application at port 12544
.
So I wonder two things :
How can I redirect this www.example.com:12544
to www.example.com
?
And the same way but for https
? I mean, https://www.example.com
?
I am really new to Glassfish
any help will be very appreciated.
The best way is to place Glassfish behind Apache http server and configure apache to point requests to glassfish. Therefore http requests are handled by Apache and all www.example.com
requests are pointed to www.example.com:12544
internally. Below is a brief explanation of how to do this.
jk
is enabled)worker.properties
file and place it into apache conf folder. It should contain the following properties:worker.list=worker1 worker.worker1.type=ajp13 worker.worker1.host=localhost worker.worker1.port=8009
httpd.conf
file in apache conf folder and place the following commands (outside Virtual Host):LoadModule jk_module modules/mod_jk.so #location of the worker file JkWorkersFile conf/worker.properties #where to put jk logs JkLogFile logs/mod_jk.log #log level [deug/error/info] JkLogLevel debug #Log format JkLogStampFormat "[%a %b %d %H:%M:%S %Y]" # Indicate to send SSL KEY SIZE JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories # Set the request format JkRequestLogFormat "%w %V %T" # Send all jsp requests to Glassfish JkMount /*.jsp worker1 # Send all webapp requests to Glassfish JkMount /* worker1
You need also to add a VirtualHost section in your conf file. This maps your domain with the path in Glassfish so Apache will be able to see it. The following tells apache to map all /myapp/* links to glassfish
<VirtualHost 111.111.111.111:80>
ServerAdmin admin@domain
ServerName domain
JkMount /myapp/* worker1
</VirtualHost>
Note: if your Glassfish listener is not created you can created from cmd using glassfish asadmin with the following command:
asadmin create-network-listener --protocol http-listener-1 --listenerport 8009 --jkenabled true jk-connector
www.example.com:12544
will be served on www.example.com
.