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

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.

main.com(wordpress)
---/mainBlog(wordpress)

I have no problems at all while surfing (main.com) but sometimes, if I call

http://main.com/mainBlog

the browser is redirected to

http://main.com:8080/mainBlog

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 http://main.com/mainBlog 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
add comment

2 Answers

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: wiki.nginx.org/Quickstart If you still have questions afterwards then go ahead and ask. –  Martin Fjordvald Jul 8 '11 at 22:54
add comment

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
add comment

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.