This is my first time am deploying spring boot in a vps and would appreciate a detailed step by step example to handle this. I am using a war file with embedded jetty server 9.4 on http.
Asked
Active
Viewed 138 times
1 Answers
1
As port 80 is the default port for http
(and http://example.com
is short for http://example.com:80
just as https://example.com
is short for https://example.com:443
because 443 is the default port for https
) you should be able to achieve this by setting the applications port to 80 by using one of the following options.
In applications.properties
server.port = 80
In applications.yml
server:
port: 80
As command line parameter
java -jar <path/to/jar> --server.port=80
As system property
java -Dserver.port=80 -jar <path/to/jar>
As an OS environment variable
SERVER_PORT = 80

Florian Cramer
- 1,227
- 1
- 16
- 29
-
I saw something like changing server.port to 80 will make jetty run as root. Is this the best approach bearing in mind somedays i might shift to https? – p.maimba Sep 08 '17 at 06:28
-
That's correct. To open any port below 1024 the application that tries to do so has to be run by root. The default port for https is 443 so it needs root permissons as well. Also see my short addition above. Another option would be to use Apache2 to forward requests from port 80 to any port (above 1024) your application runs on. See this answer for more on that: https://stackoverflow.com/a/33704078/7707166 – Florian Cramer Sep 08 '17 at 09:48
-
Thank you soo much...You are a life saver! – p.maimba Sep 08 '17 at 13:08