Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a site that uses subdirectories and currently only works when the trailing slash is added to the URL ("http://www.domain.com/dir/"). When there is no trailing slash, I get "unable to connect at server domain.com:8080" (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

2 Answers 2

I too tried but i dint find proper solution. But you can try forceful passing to backend. If www.domain.com/dir comes it should go to backend 127.0.0.1:8080/dir

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;

        proxy_pass http://127.0.0.1:8080/dir;
  }
share|improve this answer
1  
The key that I want/need is for it to go to www.domain.com/dir**/** when www.domain.com/dir 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

 
discard

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.