Nginx reverse proxy to apache adds a trailing slash at the end

Posted March 29, 2019 6.8k views
NginxApacheUbuntu 18.04

I have an nginx reverse proxy set up like this:


server {
        listen 80;
        listen [::]:80;

        root /var/www/html;
        index index.html index.htm index.nginx-debian.html;


        location / {
        proxy_pass http://localhost:8090;
        autoindex on;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;


The site is on Apache, which is listening on port 8090.

So, /etc/apache2/ports.conf looks like this:

Listen 8090

<IfModule ssl_module>
        Listen 443

<IfModule mod_gnutls.c>
        Listen 443

It works, but a trailing slash is added. So I can see my website at

I’m not sure if it’s nginx or apache causing the trailing extra slash at the end. How can I fix this?

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
1 answer


this would be from the Nginx Configuration for sure, this is a know issues with it. Most probably you’ve added a trailing slash somewhere along the way.

Please check your Nginx configuration file for the domain and make sure there is no trailing slash when doing rewrites such as :

Rewrite ^(.*)$ https://$$1;



Another problematic area might be:

 location / {
        proxy_pass http://localhost:8090/;

I know you’ve provided us with an example configuration file but please take another look to the exact domain’s file and make sure there are no leftover trailing slashes.