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

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/ <---- (all files that are public)
/var/www/ <---- (only private files)

## Serves
server {
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server ipv6only=on;

resolver valid=300s;

ssl_certificate /etc/letsencrypt/live/;
ssl_certificate_key /etc/letsencrypt/live/;

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

root /var/www/;

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/;

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

location ~ \.php$ {
include /etc/nginx/fastcgi.conf;
fastcgi_param DOCUMENT_ROOT /var/www/;

location ~ \.php$ {
include /etc/nginx/fastcgi.conf;


Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 250
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready