Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a site that uses subdirectories and currently only works when the trailing slash is added to the URL (""). When there is no trailing slash, I get "unable to connect at server" (8080 is the listening port Nginx is set up for).

I've tried adding the rewrite suggested here (and here), but it results in the "cannot connect" error for the entire virtual host.

Is there another way to add the trailing slash that I could try? Or, is there a way I can configure it to see the URL as a directory (and thus, look for the index file), regardless of the presence of the trailing slash?

share|improve this question

I too tried but i dint find proper solution. But you can try forceful passing to backend. If comes it should go to backend

location /dir {

        proxy_set_header X-Real-IP  $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

              proxy_set_header Host $host;

share|improve this answer
The key that I want/need is for it to go to**/** when is typed in. This works on my local server, which uses port 80, but not my live one, which is using port 8080. – Shauna Jul 29 '11 at 12:40

Not sure if I'm getting you wrong, but linking a file to the sites-enabled nginx directory with the following content replaces host.tld/gls with host.tld/gls/ for me if I connect to the former.

server {
    location /gls {
        root   /var/www/;
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.