Firewall – How to test Apache 2.4 using different port

apache-2.4firewall

I've got my server setup, and now I want to have Apache2 as a back-end for my Perl scripts (nginx is just too slow, and you can't use mod_perl either)

So, I have my Apache installed:

Server version: Apache/2.4.18

/etc/apache2/ports.conf, I have:

Listen 8181

<IfModule ssl_module>
    Listen 8181
</IfModule>

<IfModule mod_gnutls.c>
    Listen 8181
</IfModule>

My virtual host is pretty simple:

<VirtualHost 127.0.0.1:8181>

    LoadModule perl_module /usr/lib/apache2/modules/mod_perl.so

    LogLevel debug

    ServerName ultranerds.co.uk
    ServerAdmin info@ultranerds.co.uk
    DocumentRoot /home/rachel/web/ultranerds.co.uk/public_html
    Alias /vstats/ /home/rachel/web/ultranerds.co.uk/stats/
    Alias /error/ /home/rachel/web/ultranerds.co.uk/document_errors/
    CustomLog /home/rachel/web/ultranerds.co.uk/logs/ultranerds.co.uk.bytes bytes
    CustomLog /home/rachel/web/ultranerds.co.uk/logs/ultranerds.co.uk.log combined
    ErrorLog /home/rachel/web/ultranerds.co.uk/logs/ultranerds.co.uk.error.log

    <Directory /home/rachel/web/ultranerds.co.uk/public_html>
        Options MultiViews FollowSymLinks
        AllowOverride all
        Require all granted
        AddHandler cgi-script .cgi .pl
        Options +ExecCGI
        Options FollowSymLinks
    </Directory>
    <Directory /home/rachel/web/ultranerds.co.uk/stats>
        AllowOverride All
    </Directory>

    <IfModule mod_ruid2.c>
        RMode config
        RUidGid rachel rachel
        RGroups www-data
    </IfModule>
    <IfModule itk.c>
        AssignUserID rachel rachel
    </IfModule>

</VirtualHost>

I've enabled it with:

a2ensite ultranerds.co.uk

netstat shows it listening on 8181:

netstat -nltp|grep 8181 tcp6 0 0 :::8181
:::* LISTEN 5747/apache2

After rebooting Apache, I would have expected to be able to reach it on ultranerds.co.uk:8181 in my browser (to check its working)

What am I missing? I'm getting this error in nginx, so I'm trying to debug if its something wrong with Apache, or my nginx config:

upstream prematurely closed connection while reading response header
from upstream

UPDATE: OK, there must be something I'm not doing right. If I try:

lynx http://localhost:8181

I just get:

Alert!: Unexpected network read error; connection aborted.

I don't get why though, as I can see it here:

 netstat -an | grep 8181 | grep -i listen
tcp6       0      0 :::8181                 :::*                    LISTEN

wget also gives a fail for me:

wget http://127.0.0.1:8181
–2017-04-14 14:17:10– http://127.0.0.1:8181/
Connecting to 127.0.0.1:8181… failed: Connection refused.

I just don't get whats up. The firewall seems open, so I must be missing something. I've even tried this in apache2's ports.conf file:

Listen 8181
Listen 0.0.0.0:8181
Listen 192.0.2.1:8181

netstat is showing it as listening:

netstat -tulpn | grep :8181
tcp6       0      0 :::8181                 :::*                    LISTEN      16207/apache2

Eugh :S

Best Answer

Ok, so I ended up getting a server tech friend to take a look at this. The main thing he said, was that I needed to change Apache to run with "prefork", instead of "event":

a2dismod mpm_event
a2enmod mpm_prefork
a2enmod actions

I'm not too sure if he changed anything else, but that seems to have sorted it. I'm not too sure why that would cause an issue, but when I do my next server build, I will check to see if it works, or if I have more issues :)

Related Topic