How to setup spring-boot to allow access to the webserver from outside IP addresses

后端 未结 3 2042
傲寒
傲寒 2020-12-14 04:08

I have been looking into how to setup tomcat within spring-boot to allow access from outside IP addresses. Currently I can view the UI from locaho

相关标签:
3条回答
  • 2020-12-14 04:47

    Since so many people have viewed this question. The resolution was to make sure the firewall was configured correctly on the hosting CentOS machine and not set the server address explicitly.

    INCORRECT SETUP

    This failed previously with the firewall incorrectly setup

    server.port=8081
    server.address=192.168.0.93
    

    Once the firewall is correctly setup you do not need to specify the server.address just the port.

    CORRECT SETUP

    server.port=8081
    

    This allowed me to access the application correctly from other systems using its ip.

    http://<someip>:<server.port>
    http://192.168.0.93:8081
    
    0 讨论(0)
  • 2020-12-14 05:02

    This can be done easily by using ufw

    To view currently opened ports enter: sudo ufw status numbered (Take a screenshot just for safety)

    To open port enter: sudo ufw allow 8080 (8080 or any port you want)

    To remove port enter: sudo ufw delete {number}

    Remember to double check the number with sudo ufw status numbered before you delete it.

    :-)

    0 讨论(0)
  • 2020-12-14 05:07

    Thank you, you saved me tons! I wanted to post this in comments, but I don't have enough reputation to reply.

    Those of you who want the information regarding firewall changes,

    I used firewalld to add my springboot webserver ports in my vm(centos7)

    My webserver was using 8080, so I did:

    firewall-cmd --permanent --reload --zone=public --add-port=8080/tcp*
    
    sudo systemctl restart firewalld*
    

    you need to restart/reload the firewalld to apply the changes. if you,

    sudo firewall-cmd --list-all*
    

    you can find 8080/tcp has been added to ports list

    0 讨论(0)
提交回复
热议问题