Welcome! Log In Create A New Profile

Advanced

How should I create an alias outside the root directory in nginx?

Posted by dertin 
How should I create an alias outside the root directory in nginx?
January 30, 2018 02:50PM
Hi,

I am trying to create a protected directory that is outside the documents in the root directory.

I tried to place an alias to a directory external to the root directory of the server, but I am having trouble responding to PHP scripts.

The error he shows me is "File not found."

/var/www/website.com/htdocs <---- (all files that are public) www.website.com
/var/www/website.com/admdb <---- (only private files) www.website.com/admdb


## Serves https://www.website.com
server {
server_name www.website.com;
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server ipv6only=on;

resolver 8.8.8.8 8.8.4.4 valid=300s;

ssl_certificate /etc/letsencrypt/live/website.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/website.com/privkey.pem;

include /etc/nginx/snippets/diffie-hellman;

root /var/www/website.com/htdocs;

index index.php index.html index.htm;

include /etc/nginx/snippets/security;

location / {
try_files $uri $uri/ =404;
}

location /sendy {
access_log off;
error_log off;
rewrite ^/sendy/(l|t|w)/([a-zA-Z0-9\/]+)$ /sendy/$1.php?i=$2&$args;
rewrite ^/sendy/(u?n?subscribe)/(.*)$ /sendy/$1.php?i=$2&$args;
try_files $uri $uri/ $uri.php?$args;
}

location ^~ /admdb {

alias /var/www/website.com/admdb;

#auth_basic "Restricted Content";
#auth_basic_user_file /etc/nginx/.htpasswd;

# FIX ME
location ~ \.php$ {
include /etc/nginx/fastcgi.conf;
fastcgi_param DOCUMENT_ROOT /var/www/website.com/admdb;
fastcgi_pass 127.0.0.1:9007;
}
}

location ~ \.php$ {
include /etc/nginx/fastcgi.conf;
fastcgi_pass 127.0.0.1:9007;
}

}


regards.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 94
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready