I have Nginx installed on Ubuntu and I have the next configuration file:
server {
root /www/test;
index index.html index.htm;
server_name .dev.mysite.info;
I have HTML files in the directory /www/test and all works fine.
Now I want to change my folder to soft link:
lrwxrwxrwx 1 root root 33 Jun 17 10:39 test -> /root/Dropbox/digital_ocean/test/
But get the error message inthe browser:
"500 Internal Server Error"
Why and how can I fix it ?
Update:
root@ocean:/var/log/nginx# cat error.log
2013/06/17 11:40:27 [crit] 26197#0: *1 stat() "/www/test/" failed (13: Permission denied), client: 195.239.188.28, server: dev.meditat0r.info, request: "GET / HTTP/1.1", host: "meditat0r.info"
2013/06/17 11:40:27 [crit] 26197#0: *1 stat() "/www/test/" failed (13: Permission denied), client: 195.239.188.28, server: dev.meditat0r.info, request: "GET / HTTP/1.1", host: "meditat0r.info"
2013/06/17 11:40:27 [crit] 26197#0: *1 stat() "/www/test/index.html" failed (13: Permission denied), client: 195.239.188.28, server: dev.meditat0r.info, request: "GET / HTTP/1.1", host: "meditat0r.info"
2013/06/17 11:40:27 [crit] 26197#0: *1 stat() "/www/test/index.html" failed (13: Permission denied), client: 195.239.188.28, server: dev.meditat0r.info, request: "GET / HTTP/1.1", host: "meditat0r.info"
...
2013/06/17 11:40:27 [error] 26197#0: *1 rewrite or internal redirection cycle while internally redirecting to "/index.html", client: 195.239.188.28, server: dev.meditat0r.info, request: "GET / HTTP/1.1", host: "meditat0r.info"
The problem is how symlinks work. A symlink is basically a signpost saying "the content you're looking for is not here, you have to go look in
/root/Dropbox/digital_ocean/test/
instead". And that means that the directory/root/Dropbox/digital_ocean/test/
must be a) accessible with the same filesystem rights as the web directory, and b) that the webserver needs to be configured to allow access to that directory. I'm not an nginx expert, but I believe you will need aLocation
directive for/root/Dropbox/digital_ocean/test/
.Basic default permission for root folder is rwx----- so noone except root can read/write from it. You may:
a) Move your dropbox folder to other location (preferrable way: create separate non-root user)
b) change permissions to /root folder (never do that!)
Check your config files, the following option may be relevant.
http://nginx.org/en/docs/http/ngx_http_core_module.html#disable_symlinks