Apache2 on Slackware: VirtualHost config - connection refused on port 8080

8,257

Forbidden

You don't have permission to access / on this server.

Take a look at Apache error log, it will tell you more details.

Both. The public side is at 80, the admin/intranet side is at 8080.

For the testing purpose, add 2 hostnames into the /etc/hosts:

127.0.0.1 public.example.com
127.0.0.1 private.example.com

Change the Listen from:

Listen 127.0.0.1:80

to

Listen 80
Listen 8080

Restart Apache and make sure that Apache is listening on both port with:

netstat -nlp | grep httpd

Remove the line NameVirtualHost *:80

In <VirtualHost *:80>, change ServerName to public.example.com and in <VirtualHost *:8080>, change ServerName to private.example.com.

Restart Apache, and browse to the http://public.example.com and http://private.example.com:8080 to see what happens.

Share:
8,257

Related videos on Youtube

Bubnoff
Author by

Bubnoff

Updated on September 18, 2022

Comments

  • Bubnoff
    Bubnoff over 1 year

    I am trying to configure virtual hosts on a Slackware server and have run into a glitch.

    When I browse to localhost or 127.0.0.1 I get:

    Forbidden
    
    You don't have permission to access / on this server.
    

    I need to finish configuring the WebApp at 8080. When I browse to localhost:8080 or 127.0.0.1:8080 I get:

    Unable to connect
    
              Firefox can't establish a connection to the server at 127.0.0.1:8080.
    

    Some context: I need to duplicate the following instructions for Debian/Ubuntu on Slackware and need a hand --- so here's the Debian version:

    5. sudo ln -s /etc/koha/koha-httpd.conf /etc/apache2/sites-available/koha
    6. sudo a2enmod rewrite deflate
    7. sudo a2ensite koha && /etc/init.d/apache2 reload
    

    So far: My httpd.conf ( LoadModule stuff and comments left out )

    ServerRoot "/usr"
    Listen 127.0.0.1:80
    User apache
    Group apache
    ServerAdmin [email protected]
    ServerName localhost:80
    DocumentRoot "/srv/httpd/htdocs"
    <Directory />
        Options FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
    </Directory>
    <Directory "/srv/httpd/htdocs">
        Options Indexes FollowSymLinks
        AllowOverride None
    Order allow,deny
        Allow from all
    </Directory>
    <IfModule dir_module>
        DirectoryIndex index.html
    </IfModule>
    <Directory "/srv/httpd/cgi-bin">
        AllowOverride None
        Options None
        Order allow,deny
        Allow from all
    </Directory>
    DefaultType text/plain
    
    Include /etc/httpd/extra/httpd-vhosts.conf
    Include /etc/httpd/extra/httpd-default.conf
    

    This is a CGI app I should mention. I added the apps apache configurations to /etc/httpd/extra/httpd-vhosts.conf ( here with comments deleted ):

    NameVirtualHost *:80
    <VirtualHost *:80>
       ServerAdmin  webmaster@auction
       DocumentRoot /usr/share/koha/opac/htdocs
       ServerName localhost
       ScriptAlias /cgi-bin/koha/ "/usr/share/koha/opac/cgi-bin/opac/"
       ScriptAlias /index.html "/usr/share/koha/opac/cgi-bin/opac/opac-main.pl"
       ScriptAlias /opac-search.pl "/usr/share/koha/opac/cgi-bin/opac/opac-search.pl"
       ScriptAlias /search "/usr/share/koha/opac/cgi-bin/opac/opac-search.pl"
       ErrorLog /var/log/koha/koha-opac-error_log
       SetEnv KOHA_CONF "/etc/koha/koha-conf.xml"
       SetEnv PERL5LIB "/usr/share/koha/lib"
       <IfModule mod_gzip.c>
         mod_gzip_on yes
         mod_gzip_dechunk yes
         mod_gzip_keep_workfiles No
         mod_gzip_can_negotiate yes
         mod_gzip_update_static No
         mod_gzip_temp_dir /tmp
         mod_gzip_minimum_file_size 512
         mod_gzip_maximum_file_size 1000000
         mod_gzip_maximum_inmem_size 1000000
         mod_gzip_handle_methods GET POST
         mod_gzip_item_exclude reqheader "User-Agent: .*Mozilla/4\..*\["
         mod_gzip_item_exclude mime ^image/.*
         mod_gzip_item_exclude rspheader Content-Type:image/*
         mod_gzip_item_include file \.js$
         mod_gzip_item_include mime ^application/javascript$
         mod_gzip_item_include mime ^application/x-javascript$
         mod_gzip_item_include file \.php$
         mod_gzip_item_include mime ^text/html$
         mod_gzip_item_include file \.css$
         mod_gzip_item_include mime ^text/css$
      </IfModule>
      <IfModule mod_deflate.c>
        # Compress content with type html, text, and css, ...
        AddOutputFilterByType DEFLATE text/plain text/html text/xml text/css
        AddOutputFilterByType DEFLATE application/xml application/xhtml+xml application/rss+xml application/javascript application/x-javascript
        DeflateCompressionLevel 9
        # Properly handle old browsers that do not support compression
        BrowserMatch ^Mozilla/4 gzip-only-text/html
        BrowserMatch ^Mozilla/4\.0[678] no-gzip
        BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
        DeflateFilterNote Input instream
        DeflateFilterNote Output outstream
        DeflateFilterNote Ratio ratio
        LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate
        <IfModule mod_headers.c>
           #properly handle requests coming from behind proxies
           Header append Vary User-Agent
        </IfModule>
      </IfModule>
       Options +FollowSymLinks
       ErrorDocument 400 /cgi-bin/koha/errors/400.pl
       ErrorDocument 401 /cgi-bin/koha/errors/401.pl
       ErrorDocument 403 /cgi-bin/koha/errors/403.pl
       ErrorDocument 404 /cgi-bin/koha/errors/404.pl
       ErrorDocument 500 /cgi-bin/koha/errors/500.pl
       RewriteEngine On
       RewriteCond %{QUERY_STRING} (.*?)(?:[A-Za-z0-9_-]+)=&(.*)
       RewriteRule (.+) $1?%1%2 [N,R,NE]
       RewriteRule ^/bib/([^\/]*)/?$ /cgi-bin/koha/opac-detail\.pl?bib=$1 [PT]
       RewriteRule ^/isbn/([^\/]*)/?$ /search?q=isbn:$1 [PT]
       RewriteRule ^/issn/([^\/]*)/?$ /search?q=issn:$1 [PT]
    </VirtualHost>
    <VirtualHost *:8080>
       ServerAdmin webmaster@auction
       DocumentRoot /usr/share/koha/intranet/htdocs
       ServerName localhost:8080
       ScriptAlias /cgi-bin/koha/ "/usr/share/koha/intranet/cgi-bin/"
       ScriptAlias /index.html "/usr/share/koha/intranet/cgi-bin/mainpage.pl"
       ScriptAlias /search "/usr/share/koha/intranet/cgi-bin/search.pl"
       ErrorLog /var/log/koha/koha-error_log
       SetEnv KOHA_CONF "/etc/koha/koha-conf.xml"
       SetEnv PERL5LIB "/usr/share/koha/lib"
       Options +FollowSymLinks
       ErrorDocument 400 /cgi-bin/koha/errors/400.pl
       ErrorDocument 401 /cgi-bin/koha/errors/401.pl
       ErrorDocument 403 /cgi-bin/koha/errors/403.pl
       ErrorDocument 404 /cgi-bin/koha/errors/404.pl
       ErrorDocument 500 /cgi-bin/koha/errors/500.pl
       <IfModule mod_gzip.c>
         mod_gzip_on yes
         mod_gzip_dechunk yes
         mod_gzip_keep_workfiles No
         mod_gzip_can_negotiate yes
         mod_gzip_update_static No
         mod_gzip_temp_dir /tmp
         mod_gzip_minimum_file_size 512
         mod_gzip_maximum_file_size 1000000
         mod_gzip_maximum_inmem_size 1000000
         mod_gzip_handle_methods GET POST
         mod_gzip_item_exclude reqheader "User-Agent: .*Mozilla/4\..*\["
         mod_gzip_item_exclude mime ^image/.*
         mod_gzip_item_exclude rspheader Content-Type:image/*
         mod_gzip_item_include file \.js$
         mod_gzip_item_include mime ^application/javascript$
         mod_gzip_item_include mime ^application/x-javascript$
         mod_gzip_item_include file \.php$
         mod_gzip_item_include mime ^text/html$
         mod_gzip_item_include file \.css$
         mod_gzip_item_include mime ^text/css$
       </IfModule>
       <IfModule mod_deflate.c>
         # Compress content with type html, text, and css, ...
         AddOutputFilterByType DEFLATE text/plain text/html text/xml text/css
         AddOutputFilterByType DEFLATE application/xml application/xhtml+xml application/rss+xml application/javascript application/x-javascript
         DeflateCompressionLevel 9
         # Properly handle old browsers that do not support compression
         BrowserMatch ^Mozilla/4 gzip-only-text/html
         BrowserMatch ^Mozilla/4\.0[678] no-gzip
         BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
         DeflateFilterNote Input instream
         DeflateFilterNote Output outstream
         DeflateFilterNote Ratio ratio
         LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate
         <IfModule mod_headers.c>
           #properly handle requests coming from behind proxies
           Header append Vary User-Agent
         </IfModule>
      </IfModule>
       RewriteEngine On    
       RewriteCond %{QUERY_STRING} (.*?)(?:[A-Za-z0-9_-]+)=&(.*)
       RewriteRule (.+) $1?%1%2 [N,R,NE]
       RewriteRule ^/bib/([^\/]*)/?$ /cgi-bin/koha/detail\.pl?bib=$1 [PT]
       RewriteRule ^/isbn/([^\/]*)/?$ /search?q=isbn:$1 [PT]
       RewriteRule ^/issn/([^\/]*)/?$ /search?q=issn:$1 [PT]
    </VirtualHost>
    

    Have I missed a fundamental basic here? I should mention that the modules deflate, rewrite and perl are installed and in the LoadModule instructions.

    Thanks!

    Bubnoff

    UPDATE - with a concern/question

    First -- Thank you quanta for your help thus far. I suspected a permissions issue and added this to my httpd.conf directory stanza.

    <Directory "/srv/httpd/cgi-bin">
        AllowOverride None
        Options None
        Order allow,deny
        Allow from all
    </Directory>
    

    Changed deny from all to "allow from all". So now it works and I thank you again, however, have I just committed major security faux paux?

    • Greg Petersen
      Greg Petersen over 12 years
      Which port do you want to use: 80 or 8080?
    • Bubnoff
      Bubnoff over 12 years
      Both. The public side is at 80, the admin/intranet side is at 8080.
  • Bubnoff
    Bubnoff over 12 years
    Did as you suggested. I get "403 Forbidden" on both. No errors in either error_log or access_log. Netstat reports "LISTEN" for both 80 and 8080.
  • Greg Petersen
    Greg Petersen over 12 years
    Did you take a look at error log for Virtual Host: /var/log/koha/koha-opac-error_log, /var/log/koha/koha-error_log?
  • Bubnoff
    Bubnoff over 12 years
    I will check those tomorrow and report back. Thanks!
  • Bubnoff
    Bubnoff over 12 years
    /var/log/koha/koha-opac-error_log reports: [client 127.0.0.1] client denied by server configuration and the other log reports the same. The Apache user should have read and executable rights correct?
  • Bubnoff
    Bubnoff over 12 years
    Please see my update in my original post. It works, but I have a security concern. Thanks.
  • Greg Petersen
    Greg Petersen over 12 years
    No. Order allow,deny means that Allow rules are processes before Deny rules. So, if you use Deny from all your clients would be denied access.