Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Well, I'm really confused. I have a web server running nginx inside a virtual machine. I'm fowarding the port 8082 from the host machine to the port 80 in the virtual machine. In fact, going to works as expected showing the web page.

The problem happens when I type a url like this

The browser redirect me to without the port number, so nothing works. But if I add a trailing backslash in the url like this it works properly.

My question is, how can I point and to the same place and how I prevent nginx from removing the port number?

If is important, this is my actual nginx configuration inside the virtual machine:

server {
    listen 80;
    root /srv/www/exampledomain;
    index index.php;
    rewrite ^([^.]*[^/])$ $1/ permanent;

    location /subdirectory {
        try_files $uri $uri/ /subdirectory/index.php?$args;
share|improve this question

1 Answer 1

up vote 1 down vote accepted

The simplest fix is to change your rewrite to

rewrite ^([^.]*[^/])$$1/ permanent;
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.