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

A really simple one but it's alluding me entirely.

I've set up nginx as a proxy for Apache and at the moment it's only set to allow requests for certain files through to Apache, the config line is below. Problem I'm having, I need it to send .htaccess through also and every change I've tried has failed! Probably someone has done this before, it's a pretty standard setup.

location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|wav|bmp|rtf|js)$ {root /var/www;}

I would hardcode them into the nginx.conf but there's a lot of rewrites. A lot easier to let Apache handle them.

Thanks in advance!

share|improve this question
up vote 0 down vote accepted

By ".htaccess request" and "send .htaccess through" you seem to be implying that the web browser should request the .htaccess file and the web server should deliver it. This really isn't now it's supposed to work, it's so far off I'm sure I've misunderstood.

What .htaccess is actually for is for giving apache specific options based on what folder a file is in; the browser requests something from nginx, nginx passes the request to apache, apache reads the .htaccess file and runs any commands inside it, then apache reads the file that was asked for and returns that back to the user.

The latter is a standard setup, so maybe that's what you mean? If the latter is what you want, make sure that the .htaccess / apache setup is working when you access apache directly; if not, get it working there before adding nginx in front. If it is working with just apache, then check the nginx access and error logs to see what requests it is forwarding along.

share|improve this answer
I'm an idiot, didn't do my Apache config properly. Thanks! – Max Dec 3 '11 at 9:37

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.