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

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 successfully able to setup nginx and apache combination to serve wordpress blog with the help of this site. I exactly followed all the codes supplied in that site and following is the directory strcture of my blog and sub-blog.

I have no problems at all while surfing ( but sometimes, if I call

the browser is redirected to

and got "Cannot connect to server" error from browser. "8080" is used as proxy port where nginx transfer all dynamic content traffics to Apache. But if I type this again in the same address bar, problem disappear again. It would be annoy to users who doesn't know to reload the page without "8080" port.

Edit: I just found out that, if I leave slash at the end of the url, I got that problem but if I put slash, no problem at all. Where can I define for that problem?

share|improve this question

This is actually Apache (or PHP) sending the redirect, so you need to fix it there, you cannot change this in Nginx unless you want to actively make nginx redirect no trailing slash to trailing slash.

rewrite ^(.*[^/])$ $1/ permanent; will do it.

share|improve this answer
Thanks a lot Martin. Would u mind if I ask where to put that line? I'm not very good with server things and still learning. – Devyn Jul 8 '11 at 18:43
Hi! I suggest you read this: If you still have questions afterwards then go ahead and ask. – Martin Fjordvald Jul 8 '11 at 22:54

I had a similar problem with varnish and nginx (varnish on port 80 proxying to nginx listening on 8080) and needed to add "port_in_redirect off;" ... server_name_in_redirect needed to stay on so nginx knew which host it was handling.

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.