Skip to content
OSULZER.AT
Server2 min read· updated May 18, 2023

ERR_TOO_MANY_REDIRECTS with Apache and NGINX Proxy Manager

Apache behind NGINX Proxy Manager throws ERR_TOO_MANY_REDIRECTS because headers are not forwarded. Two ways to fix it, from quick and dirty to clean.

For everyone interested in homelabs, or anyone who likes to run their local development environment with an SSL certificate, here is a handy snippet. If you want to access an Apache instance through NGINX Proxy Manager, the default configuration means the pages do not want to load, and after a while the error message ERR_TOO_MANY_REDIRECTS appears. The reason is that the header information is not forwarded to Apache. If there are further technical subtleties that cause the error, feel free to email me and I will extend this article accordingly.

There are basically two approaches.

“Quick and dirty”:

If you run PHP projects, the following server variable has to be set for each project:

$_SERVER['HTTPS'] = 'On';

That is all, and the page in question should load. This solution is of course not very pretty, and this piece of code would be unsightly especially if you want to publish the site later.

“Normal Mode”

In NGINX Proxy Manager, place the following lines under Advanced in the entry that points to your Apache server:

proxy_read_timeout 300;
proxy_pass_header  X-Transmission-Session-Id;
proxy_set_header   X-Forwarded-Host   $host;
proxy_set_header   X-Forwarded-Server $host;
proxy_set_header   X-Forwarded-For    $proxy_add_x_forwarded_for;

On your server, you now enable the Apache extension mod_remoteip with the following command:

sudo a2enmod remoteip

Now open your vHost config file (it should be located in /etc/apache2/sites-enabled/) and add the following information. The important part is the section between the two hash symbols:

<VirtualHost *:80>
	#
	RemoteIPHeader X-Forwarded-For
	RemoteIPInternalProxy ip.eures.proxy.managers
	SetEnvIf X-Forwarded-Proto "^https$" HTTPS=on
	#
</VirtualHost>

Then we reload our config with the following command.

sudo systemctl reload apache2.service

That’s it, now it should work.

Maintenance & Operations

Hand off your server worries?

Updates, backups, and monitoring - so your website runs reliably.

See maintenance
Server2 min

Enable Wake on LAN in Proxmox / Debian

Wake on LAN powers on your server over the network with a magic packet. This guide shows the Linux setup with ethtool under Proxmox and Debian.

Server4 minArchive

Linux Root Server / vServer Monitoring

Your own root server or vServer needs monitoring. An overview of tools like UptimeRobot, htop, Logwatch, NetData and Nagios that alert you when it fails.

New project?

Contact.

Tell me briefly about your project - I'll get back to you personally.

Your data is used solely to handle your inquiry. More in the privacy policy.