How can I set up Apache to use port 1 and other ports below 80?

I'm going to use Firefox as an example, because its open source and easy to find the information for, but this applies (probably with slightly different lists of ports) to other browsers, too.

In August 2001, CERT issued a vulnerability note about how a web browser could be used to send near-arbitrary data to TCP ports chosen by an attacker, on any arbitrary IP address. This could be used to, for example, send emails which would appear to come from the user running the web browser. In order to mitigate this, Mozilla (as well as many other vendors) blocked Firefox from accessing certain ports.

The two ports you tried, 79 and 1, happen to be on the blocklist. The source contains the full list of blocked ports. You can (on your browser) override this list using the preferences network.security.ports.banned.override and network.security.ports.banned. This isn't useful on the Internet in general, as you'd have to convince everyone who might visit your site to go to about:config and change them.

(Note: Current versions of Firefox will give an error message explaining that if you try to browse to a site on a blocked port.)

In general, there is little reason to use additional HTTP ports, at least externally. If you have to, prefer traditional extra ports like 8080, 8000, etc. that are far less likely to be blocked or at least ones outside of the IANA-assigned system ports range (0-1023). See the IANA port registry for more details.


apache restarts just fine but on the web it does not work.

Port 80 is the default HTTP port for browsers as well as servers. This means in order to access a server that's operating on a non-standard port from a browser, you need to include the port in the address, e.g.:

http://localhost:79/rest/of/url

Without the :79 after the hostname, the browser will try to access port 80 and get nothing since apache is using something else.