I for the life of me cannot figure out how to make aliases for locations.
Basically, I have /var/www
on my server, which could contain any number of folders (for different applications). One of those is ViMbAdmin, located in /var/www/vimbadmin
, and the actual web files that should be served to the client are in /var/www/vimbadmin/public
. Here's what I have so far, which is failing:
server {
listen 80;
server_name myserver.com;
root /var/www;
index index.php;
# Logs
access_log /var/log/nginx/vimbadmin.access.log;
error_log /var/log/nginx/vimbadmin.error.log;
location /vimbadmin/public {
try_files $uri $uri/ /index.php?$args;
}
location /mail2admin {
alias /vimbadmin/public;
}
# Pass the PHP scripts to FastCGI server
location ~ \.php$ {
# Prevent Zero-day exploit
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
My goal is to set it up so that hackers can't just try to go to http://myserver.com/vimbadmin
, so the actual URL will be http://myserver.com/mail2admin
. What am I doing wrong? I'm really confused about the relationships between root
, location
, and alias
.