Question

Access Apache Site Externally

Posted January 13, 2021 385 views
ApacheWordPressLAMP StackNetworkingFirewallUbuntu 20.04

Good night,

I setup Ubuntu 20.04 server, and installed LAMP stack and Wordpress for a site.

I can access the site internally (from another PC,phone,etc…) at the servers IP on port 80. Externally, jjohns.ddns.net:8821, the site will not load. I am sure my port forwarding is correct as I host a few sites here at my house. I have several which work using IIS on Windows 10.

In this sites /etc/apache2/sites-available/jmcs.conf I have the following:

<VirtualHost *:80>
        #ServerName ##This is commented out at the moment, but I have tried using the domain name jjohns.ddns.net for both name/alias
        #ServerAlias
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/jmcs
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
        <Directory /var/www/jmcs/>
               AllowOverride All
        </Directory>
</VirtualHost>                

In the ports.conf


Listen 80

<IfModule ssl_module>
        Listen 443
</IfModule>

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

UFW I am not too familiar with what may need to be opened, but I have it inactive at the moment. Status while active is:

Status: active

To                         Action      From
--                         ------      ----
22/tcp                     ALLOW       Anywhere
Apache                     ALLOW       Anywhere
22/tcp (v6)                ALLOW       Anywhere (v6)
Apache (v6)                ALLOW       Anywhere (v6)

On my Edge Router, using TCP, I forward from 8821 to port 80. I have tested going from 80 to 80 and it did not work. Also tired UDP, and both TCP/UDP for giggles.

Any assistance is much appreciated.

–Leavii

edited by KFSys

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
2 answers

Hi @Leavii,

Have you symlinked the conf file in the sites-enabled folder as well?

Additionally, once you enable the ServerName directive in your configuration file with a valid domain and restart apache, you should be able to reach that domain on port 80. I’m not sure why you are trying to reach it on port 8821.

Regards

  • Thanks for the reply @KFSys.

    I was unaware of what symlink was until you asked this question so I have not done that step. Which file do I link to the jmcs.conf? From a little reading it would look like I need to run the below command. Still quite new to Linux so I apologize for that.

    ln -s /etc/apache2/sites-available/jmcs.conf /etc/apache2/sites-enabled/jmcs.conf

    I externally open port 8821 just to forward it to port 80 in this case. Most sites I have here aren’t on port 80 internally or externally, but just a random port I picked. The only reason I have done this is because this is how I have always done it in IIS on Windows and it has always worked. With my old firewall I was unable to change its remote managing from anything but port 80. So it was always taken and I have never changed it when I got new hardware.

    I have also used NoIP for a while for DNS names. Will the jjohns.ddns.net not work for the ServerName in jmcs.conf file? I have tried it previously with no success, but unaware if I was missing something. I am also unaware if it matters that I am using jmcs instead of jjohns.ddns.net for the conf files, and virtual host file.

    Again, thank you for your reply.

  • @KFSys

    I have opened port 80 to the server, enabled ServerName to ServerName jjohns.ddns.net, left ServerAlias commented out, and restarted the Apache2 service. Still no luck.

    I checked for linked files with this answer and the result was 1183611 0 lrwxrwxrwx 1 root root 28 Jan 11 01:00 /etc/apache2/sites-enabled/jmcs.conf -> ../sites-available/jmcs.conf

    I take it that during setup I linked the files at some point. Not sure if you are available to help any further, but as I am hunting for what I am missing I thought I’d update my progress.

  • Found the issue is not that I cannot reach the site, but it will not load wordpress or that it very very slow. I currently have index.html up and I can reach the server so the issue is in wordpress. I believe I will need to make a new question, but I will give this sometime in case someone comes across to review it or I find a solution to the loading speed externally.

    • Hi @Leavii,

      Thank you for the confirmation. Okay, if it’s the speed there should be something to indicate what is it.

      Can you try to open the website and see in your logs when do you receive the connection? You can see that from the apache access log, you’ve specified in your config:

      CustomLog ${APACHE_LOG_DIR}/access.log combined
      
      • @KFSys Thank you for directing me to the correct log file. As I am unfamiliar with a LAMP stack I was unaware of where to look as obvious as it is to google such an answer.

        Below is the timeout error from an external connection where I am having speed issues.

        71.142.228.39 - - [15/Jan/2021:14:08:33 -0600] "-" 408 0 "-" "-"
        

        I have increased the timeout in /etc/apache2/sites-available/jmcs.conf to 600 and restarted apache2 service, but it doesn’t seem to help.

        Here is the full log for this external connection in case I missed something.

        71.142.228.39 - - [15/Jan/2021:14:07:41 -0600] "GET /wordpress HTTP/1.1" 404 12700 "http://jackiesmcs.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36"
        71.142.228.39 - - [15/Jan/2021:14:07:42 -0600] "GET /wp-content/uploads/2021/01/cropped-truck-favicon-32x32.png HTTP/1.1" 200 1104 "http://jackiesmcs.com/wordpress" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36"
        71.142.228.39 - - [15/Jan/2021:14:07:43 -0600] "GET /wordpress HTTP/1.1" 404 12699 "http://jackiesmcs.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36"
        71.142.228.39 - - [15/Jan/2021:14:07:44 -0600] "GET /wp-content/uploads/2021/01/cropped-truck-favicon-32x32.png HTTP/1.1" 200 1104 "http://jackiesmcs.com/wordpress" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36"
        71.142.228.39 - - [15/Jan/2021:14:07:47 -0600] "GET /wordpress HTTP/1.1" 404 12699 "http://jackiesmcs.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36"
        71.142.228.39 - - [15/Jan/2021:14:07:48 -0600] "GET /wp-content/uploads/2021/01/cropped-truck-favicon-32x32.png HTTP/1.1" 200 1104 "http://jackiesmcs.com/wordpress" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36"
        71.142.228.39 - - [15/Jan/2021:14:08:33 -0600] "-" 408 0 "-" "-"
        174.195.17.222 - - [15/Jan/2021:14:23:50 -0600] "GET /wordpress HTTP/1.1" 404 12700 "http://jackiesmcs.com/" "Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 EdgiOS/45.12.0 Mobile/15E148 Safari/605.1.15"
        174.195.17.222 - - [15/Jan/2021:14:23:51 -0600] "GET /wp-includes/js/wp-emoji-release.min.js?ver=5.6 HTTP/1.1" 200 5022 "http://jackiesmcs.com/wordpress" "Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 EdgiOS/45.12.0 Mobile/15E148 Safari/605.1.15"
        174.195.17.222 - - [15/Jan/2021:14:23:51 -0600] "GET /wp-content/themes/car-fix-lite/css/nivo-slider.css?ver=5.6 HTTP/1.1" 200 1536 "http://jackiesmcs.com/wordpress" "Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 EdgiOS/45.12.0 Mobile/15E148 Safari/605.1.15"
        174.195.17.222 - - [15/Jan/2021:14:23:51 -0600] "GET /wp-includes/css/dist/block-library/style.min.css?ver=5.6 HTTP/1.1" 200 8193 "http://jackiesmcs.com/wordpress" "Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 EdgiOS/45.12.0 Mobile/15E148 Safari/605.1.15"
        174.195.17.222 - - [15/Jan/2021:14:23:51 -0600] "GET /wp-content/themes/car-fix-lite/style.css?ver=5.6 HTTP/1.1" 200 6870 "http://jackiesmcs.com/wordpress" "Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 EdgiOS/45.12.0 Mobile/15E148 Safari/605.1.15"
        174.195.17.222 - - [15/Jan/2021:14:23:51 -0600] "GET /wp-content/themes/car-fix-lite/fontsawesome/css/fontawesome-all.css?ver=5.6 HTTP/1.1" 200 9822 "http://jackiesmcs.com/wordpress" "Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 EdgiOS/45.12.0 Mobile/15E148 Safari/605.1.15"
        174.195.17.222 - - [15/Jan/2021:14:23:51 -0600] "GET /wp-includes/js/jquery/jquery-migrate.min.js?ver=3.3.2 HTTP/1.1" 200 4520 "http://jackiesmcs.com/wordpress" "Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 EdgiOS/45.12.0 Mobile/15E148 Safari/605.1.15"
        174.195.17.222 - - [15/Jan/2021:14:23:51 -0600] "GET /wp-content/themes/car-fix-lite/css/responsive.css?ver=5.6 HTTP/1.1" 200 2255 "http://jackiesmcs.com/wordpress" "Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 EdgiOS/45.12.0 Mobile/15E148 Safari/605.1.15"
        174.195.17.222 - - [15/Jan/2021:14:23:51 -0600] "GET /wp-content/themes/car-fix-lite/js/jquery.nivo.slider.js?ver=5.6 HTTP/1.1" 200 5239 "http://jackiesmcs.com/wordpress" "Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 EdgiOS/45.12.0 Mobile/15E148 Safari/605.1.15"
        174.195.17.222 - - [15/Jan/2021:14:23:51 -0600] "GET /wp-includes/js/jquery/jquery.min.js?ver=3.5.1 HTTP/1.1" 200 31269 "http://jackiesmcs.com/wordpress" "Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 EdgiOS/45.12.0 Mobile/15E148 Safari/605.1.15"
        174.195.17.222 - - [15/Jan/2021:14:23:51 -0600] "GET /wp-includes/js/wp-embed.min.js?ver=5.6 HTTP/1.1" 200 1118 "http://jackiesmcs.com/wordpress" "Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 EdgiOS/45.12.0 Mobile/15E148 Safari/605.1.15"
        174.195.17.222 - - [15/Jan/2021:14:23:51 -0600] "GET /wp-content/themes/car-fix-lite/js/editable.js?ver=5.6 HTTP/1.1" 200 1090 "http://jackiesmcs.com/wordpress" "Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 EdgiOS/45.12.0 Mobile/15E148 Safari/605.1.15"
        174.195.17.222 - - [15/Jan/2021:14:23:51 -0600] "GET /wp-content/themes/car-fix-lite/images/search-icon.png HTTP/1.1" 200 833 "http://jackiesmcs.com/wordpress" "Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 EdgiOS/45.12.0 Mobile/15E148 Safari/605.1.15"
        174.195.17.222 - - [15/Jan/2021:14:23:51 -0600] "GET /wp-content/themes/car-fix-lite/images/mobile-nav.png HTTP/1.1" 200 487 "http://jackiesmcs.com/wordpress" "Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 EdgiOS/45.12.0 Mobile/15E148 Safari/605.1.15"
        174.195.17.222 - - [15/Jan/2021:14:23:51 -0600] "GET /wp-content/themes/car-fix-lite/fontsawesome/webfonts/fa-solid-900.woff2 HTTP/1.1" 200 50660 "http://jackiesmcs.com/wordpress" "Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 EdgiOS/45.12.0 Mobile/15E148 Safari/605.1.15"
        174.195.17.222 - - [15/Jan/2021:14:23:54 -0600] "GET /wp-content/themes/car-fix-lite/fontsawesome/webfonts/fa-regular-400.woff2 HTTP/1.1" 200 12477 "http://jackiesmcs.com/wordpress" "Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 EdgiOS/45.12.0 Mobile/15E148 Safari/605.1.15"
        71.142.228.39 - - [15/Jan/2021:14:24:00 -0600] "GET /wordpress HTTP/1.1" 404 12700 "http://jackiesmcs.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36"
        71.142.228.39 - - [15/Jan/2021:14:24:01 -0600] "GET /wp-content/uploads/2021/01/cropped-truck-favicon-32x32.png HTTP/1.1" 200 1104 "http://jackiesmcs.com/wordpress" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36"
        174.195.17.222 - - [15/Jan/2021:14:24:13 -0600] "GET / HTTP/1.1" 200 831 "-" "Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 EdgiOS/45.12.0 Mobile/15E148 Safari/605.1.15"
        174.195.17.222 - - [15/Jan/2021:14:24:15 -0600] "GET /wordpress HTTP/1.1" 404 12700 "http://jackiesmcs.com/" "Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 EdgiOS/45.12.0 Mobile/15E148 Safari/605.1.15"
        174.195.17.222 - - [15/Jan/2021:14:24:15 -0600] "GET /wp-content/uploads/2021/01/cropped-truck-favicon-180x180.png HTTP/1.1" 200 9242 "-" "RubyBrowser/45.12.0 (iPhone; iOS 14.3; Scale/2.00)"
        71.142.228.39 - - [15/Jan/2021:14:24:15 -0600] "GET /wordpress HTTP/1.1" 404 12700 "http://jackiesmcs.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36"
        71.142.228.39 - - [15/Jan/2021:14:25:04 -0600] "-" 408 0 "-" "-"
        

        I also now have a domain name jackiesmcs.com and entered the server name and alias in the conf file so it currently contains:

        <VirtualHost *:80>
                ServerName jackiesmcs.com
                ServerAlias www.jackiesmcs.com
                ServerAdmin webmaster@localhost
                DocumentRoot /var/www/jmcs
                ErrorLog ${APACHE_LOG_DIR}/error.log
                CustomLog ${APACHE_LOG_DIR}/access.log combined
                Timeout 600
        
                <Directory /var/www/jmcs/>
                        AllowOverride All
                </Directory>
        
        </VirtualHost>
        

        Appreciate the help!

      • Found the issue to be my header image file size. It was originally 1.26MB. I have it compressed to 35KB and site loads fine. For me at least. Going to test more remote clients to be safe but for now I believe it was my header file size.

        Any information you have on this to confirm that this could have been my issue I would greatly appreciate as I have never had this issue before on any other site I have hosted, but I have never used WP or a Linux host.

        Thank you for your time, and assistance!

Hi @Leavii,

That’s great! I’m glad you were able to resolve the issue!

Let me know how the tests go. Additionally, try and increase your apache workers, they might be filling up as well. This setting can be increased in the main apache configuration file(not the one with your domain information in it).