Denying access to server IP and ports



  • So I've got my forum running, and nginx set up as a proxy. Now I want to deny access to ports 80 and 4567 on my server through its IP address, so people can only visit my forum through example.com, instead of through 123.456.789.101:80 and 123.456.789.101:4567 as well.

    Is there an nginx config I could use that will do that?



  • @luke Visiting IP:80 should return you to IP (without port) as that's what your nginx config tells it to do. (listen 80 { server block } etc etc)

    I've never tried it, but you could probably add a listener on port 4567 as well as 80. However I don't know if this would affect how listen 80 would reverse proxy your site to 4567, if 4567 is redirecting back to <IP address>

    If I'm not mistaken, example.com IP:80 and IP:4567 will all be identical anyway. As is my understanding.

    EDIT: Bug report, FPT and Y all overlap the colon symbol with no spaces.

    F:
    P:
    T:
    Y:



  • So there isn't a way to make nginx monitor listen for requests on 1.2.3.4:4567 and 1.2.3.4:80 and block those requests or redirect them to my domain?

    Not seeing a bug btw.


  • GNU/Linux Admin

    Take a look at this article: http://nginx.org/en/docs/http/server_names.html#miscellaneous_names

    Adding a new server block with your IP address in the server_name field should catch those...:

    server {
      listen 80;
      listen 4567;
      server_name 123.456.789.101;
    
      return 301 http://lukesawesomeforum.com;
    }
    

    I apologise in advance for my most likely not working nginx code ­čść


Log in to reply
 

Suggested Topics

  • 6
  • 6
  • 2
  • 1
  • 6
| |