0

Is it possible to configure Apache to not listen on port 80 when connecting from localhost, but allow the connection on port 80 from an external IP?

2
  • 2
    you can block with iptables access from localhost to port 80 while allowing all other traffic, what are you trying to achieve? Apr 3, 2014 at 17:42
  • Because I need the port 80 on localhost released to another application that also uses port 80, but this application lets not change the door Need to somehow free up port 80 to localhost and I need that Apache continues to function externally. Sorry my english Apr 3, 2014 at 17:47

1 Answer 1

1

You can do this with multiple listen directives

Listen 192.0.2.1:80
Listen 203.0.113.1:80

Multiple Listen directives may be used to specify a number of addresses and ports to listen to. The server will respond to requests from any of the listed addresses and ports.


On a CentOS System I have to hand

Listen 192.168.254.16:80

netstat -tnlp | grep :80
tcp     0   0 192.168.254.16:80       0.0.0.0:*      LISTEN      15014/httpd

telnet localhost 80
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused

Connection Refused generally means nothing is listening which can be seen from the netstat output.

Listen 80

netstat -tnlp | grep :80
tcp        0      0 :::80            :::*      LISTEN      15135/httpd

telnet localhost 80
Trying ::1...
Connected to localhost.
Escape character is '^]'.
3
  • I did it, but he keeps coming up on localhost Apr 3, 2014 at 17:49
  • @user2577532: This works as expected on a CentOS system I have to hand.
    – user9517
    Apr 3, 2014 at 18:04
  • Thanks Iain, worked perfectly! I was doing the wrong file apache2.conf the correct file is ports.conf Thank you very much! Apr 3, 2014 at 18:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .