i would like the site you currently have at http://ipserver:8080/project/ to be served as www.example.com. I use glassfish server. Thanks
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Good morning, yesterday configure from digital ocean and nginx as they left me in the last comment, but until now I do not work the url with the www. Am I missing something else?
I send you my settings.
In nginx in the example.com file
** In digital ocean **
*A @ --> ipServer
CNAME www --> @*
Yes, i use digital ocean. Try it. Thanks
It worked perfect. The only detail left is:
example.com works www.example.com not work
I need some configuration to accept the www?
Thanks again!
Great!! Nginx was installed already. Now, you could tell me how would the /etc/nginx/sites-enabled/default file for the case of using 2 or more projects in different urls?
Example
159.203.100 … :8080/ Project1 to www.project1.com 159.203.100 … :8080/ Project2 to www.project2.com
Thank you very much!!!
You need a Reverse Proxy. As you use Nginx (assuming from tag), it’s very simple.
Open your default server block (or any you want to use):
Find `location / block and delete any content from it. Make sure it looks like this:
Save file, exit editor and restart nginx:
You should get desired results. To learn more about it, you can refer to this tutorial which covers both Nginx and Apache. I personally recommend Nginx as it better suit reverse proxy needs.
There are two ways to accomplish this, either reconfigure Glassfish to listen on port 80 or install an nginx reverse proxy in front of it.
##Option 1
To have Glassfish listen on port 80:
Connect to the administration interface (by default on port :4848)
In the left menu go to Configurations
Then select the appropriate configuration you need to change eg server-config
Then go to Network Config
Then go to Network Listeners
Select the appropriate listener, probably http-listener-1
Change the Port value to 80
Save and reboot your glassfish server/instance/cluster according to your needs
##Option #2
To configure an nginx reverse proxy, first install nginx. On Ubuntu this can be done with
sudo apt-get install nginx
. Once installed, open the file/etc/nginx/sites-enabled/default
and modify it so it reads:Then restart nginx for the changes to take effect: