Bobcares

How we redirect port 80 to 8080 in Apache and fix related errors

by | Sep 6, 2019

Web server listens on port 80 by default.

But for running applications like Tomcat or JBoss on the same server, we need to redirect port 80 to 8080 in Apache configuration.

However, it may not always work due to improper Apache settings and ends up in website errors.

At Bobcares, we often get requests from our customers to fix redirect port 80 to 8080 apache errors as part of our Server Management Services.

Today, this write-up describes how our Support Engineers fix Apache port redirection errors.

 

How to redirect port 80 to 8080 in Apache

It’s pretty easy to route Apache to another port. Let’s see how our Support Engineers route port 80 to 8080.

1. Initially, we login into the server as a root user.

2. Then, we create the file /etc/apache2/other/port8080-redirect.conf.

nano -w /etc/apache2/other/port8080-redirect.conf

3. After that, we add the following code into the file and save it.

<VirtualHost _default_:80>
DocumentRoot /home/user/website_folder
RewriteEngine On
# Redirect all requests to the local Apache server to port 8080
RewriteRule ^.*$ http://%{HTTP_HOST}:8080%{REQUEST_URI}
</VirtualHost>

Document root may vary with server settings.

4. At last, we restart the Apache service.

apachectl restart

In addition, this port redirection set up with Apache module mod_proxy. For this, we should enable mod_proxy on the server.

 

How we fixed the common errors

At Bobcares, where we have more than a decade of expertise in managing servers, we see many customers face problems while redirecting port 80 to 8080 in Apache.

Now let’s see how our Support Engineers fixed the top errors.

 

1. Incorrect proxy settings

Recently, one of our customers had a problem while redirecting port 80 to 8080 in Apache.  He got an error when restarting the apache service after updating the rule in the apache configuration file, The error said,

Syntax error on line 207 of /etc/apache2/apache2.conf: Syntax error on line 1 of /etc/apache2/httpd.conf: Cannot load /etc/apache2/modules/mod_proxy.so into server: /etc/apache2/modules/mod_proxy.so: cannot open shared object file: No such file or directory
Action '-k graceful' failed.

It was clearly a syntax error in specifying the proxy module. So, we correctly added a line to load proxy_module in httpd.conf.

LoadModule proxy_module modules/mod_proxy.so

And, we ensured that the file exists with correct permissions.

Also, in the path set in DocumentRoot, we edited the links for each application in Tomcat’s web apps directory. Otherwise, the HTTP server will not be able to load resource files, like CSS and JS.

That fixed the problem and the website started working fine.

 

2. Wrong firewall

A common error when using custom Apache ports relates to the server firewall. Often server owners fail to open port 8080 in the server. This can cause the website to fail.

Therefore our Dedicated Engineers open port using the firewall application that the server uses. For instance, in iptables, we use:

iptables -I INPUT -p tcp --dport 8080 -j ACCEPT 

Or when the server has Plesk control panel, we open port from admin panel at:

 

3. Missing Module

Similarly, customers often complaints that the port forwarding is not working on their server. They may consider that it may happen due to improper port settings in the server. However, web apps like Tomcat need a mod_proxy module that easily routing a Tomcat web app to an Apache frontend.

Therefore, our Support Engineers ensure that the mod_proxy and mod_proxy_http enabled on the server. If not we’ll enable it for the proper working of port forwarding.

[Need assistance in port forwarding and to fix related errors? We’ll help you.]

 

Conclusion

In short, when redirecting port 80 to 8080 in Apache, error may happen due to the improper settings in the configuration file. Today, we saw how our Support Engineers fix redirect port 80 to 8080 apache related errors.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF