I am running an application on port 7000 which is part of a network. So it has to communicate over port 7000 with all other servers of the network (not LAN, dynamic IPs). It has also a web frontend you can access at http://my.ser.ver.ip:7000 but I want to block the access to the webfront end. How is this possible without block my application at all?

  • 1
    In your question you say that your application needs to communicate over port 7000 and you also say that you want to block port 7000. You can't have it both ways. Can you please edit your question and clarify? Perhaps you're getting source port and destination port mixed up? – EEAA Apr 4 '16 at 1:03
  • If I'm reading this correctly, you want to block only traffic specifically using HTTP as an application-level protocol, and not all traffic to port 7000, just HTTP traffic. If that's the case, you've painted yourself into a kind of small corner, and you're getting into content-aware firewalls and DPI. I won't say it's impossible, but I will say it'd probably be a lot easier to simply run HTTP traffic on a different port. – Parthian Shot Apr 4 '16 at 13:36

If i understood your question correctly, you have multiple ways to block access to your application from outside the server.

  1. You can set your application to work only with a IP address.
  2. You can block it via iptables.

My best practice is the first option.


You can block this via .htaacess file. In .htaccess fle you need to allow application only via your public IP address and deny all other IP address. Below i have shared the content which needs to be entered in .htaccess file.

 Order deny,allow
 allow from  #Your Public IP, only this IP is accessible to application.
 deny from all

This will sort out the problem for you.


You need to block any access to port 7000, then allow access to port 7000 to only the servers in your network. That way you effectively block the Web UI from being accessed unless you're accessing it from a server inside your network.

HTTP is a protocol (P in HTTP) and runs on port 80. UFW can't block it based on it being a web page or not since it only manages iptables, and only knows it's a web page after a connection has been established.

Depending on which web server you use, you could possible use imvikasmunjal's suggestion. However "block all to access port 7000" and then giving specific access to specific IP's is the best way forward IMO

  • Sorry, if I communicated it wrong. The network is not a LAN network. We are talking about servers around the globe and their IP are not always static and may change. What about using NGINX as a reverse proxy? I tried it by one DigitalOcean tutorial but I were not able to make it work. – John Doof Apr 19 '16 at 13:55
  • Well, in my opinion then, put the web front-end on port 80 and have it communicate with whatever it needs to on port 7000, then block access with a normal authentication request that a web server has built in – zerohero Apr 20 '16 at 7:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.