bielas
bielas

Reputation: 712

Make AWS listening for SpringBoot app on 80 port

I have created a Spring Boot application which by default is working on 8080 port. In my AWS EC2 dashboard called security groups I set: enter image description here

And when I run from command my app which is already one the server I have to provide a url like: blablab.compute.amazonaws.com:8080 -> so I have to provide port on which app is running. How to set AWS settings to not providing port in the end and that my app will work properly?

Upvotes: 1

Views: 1490

Answers (2)

Ashish Ramtri
Ashish Ramtri

Reputation: 81

You could actually go to your aws console.

Console-->Configuration(on the left pane)-->Click Edit button against the Software card-->scroll all the way down to Environment properties-->And add the below under name and value respectively:

SERVER_PORT || 8080

Finally, click on apply.

And voila!! You are good to go now.Reference to AWS Console Page

Upvotes: 0

Rick Baker
Rick Baker

Reputation: 903

Couple possible solutions.

1) Use a load balancer in front of your server, and set that so the load balancer listens on port 80 and forwards the requests to port 8080 of the server.

2) Use iptables on the server and have it forward port 80 to port 8080. Something like:

iptables -A INPUT -i eth0 -p tcp --dport 80 -j ACCEPT
iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080

Upvotes: 1

Related Questions