I have a nginx installation which I need for hosting web sites in development so that other people can test them out.
Right now I've set up a virtual host for a single sub-domain and in that directory I symlink projects which should be open for testing. As you can see have I restricted access to the whole site but enabled for the specific directory, but keeping it private with a simple auth_basic.
The PHP runs but I keep getting 404s for anything other than / or /wp-admin/, all the other permalinks gives 404s. I've done just about everything to get this to work but I have no idea what I'm doing wrong. Please point out my error in the following configuration:
server {
listen 80;
server_name dev.example.com;
client_max_body_size 20m;
server_tokens off;
root /srv/dev.example.com;
index index.php index.html index.htm;
location / {
deny all;
}
location /my-site {
allow all;
try_files $uri $uri/ /index.php?$args;
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/auth.d/.htpasswd-my-site;
location ~ \.php$ {
include fastcgi_params;
fastcgi_index index.php;
fastcgi_pass php5-fpm-sock;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_intercept_errors on;
fastcgi_param HTTPS $https;
}
}
}
Thank you!
UPDATE:
This request would work: http://dev.example.com/my-site/
, it would result in loading the file /srv/dev.example.com/my-site/index.php
.
A request to the wordpress admin interface would work too: http://dev.example.com/my-site/wp/wp-admin
, also going directly to an index file: /srv/dev.example.com/my-site/wp/wp-admin/index.php
. Everything within the admin interface works since it doesn't use permalinks but the raw GET input.
However, as soon as I attempt to load a permalink (I use the most simple format /%postname%/
) it fails in finding it and the try_files directive in location /my-site {}
should match them. This means that routes such as the following doesn't work:
http://dev.example.com/my-site/about
http://dev.example.com/my-site/contact
http://dev.example.com/my-site/etc