Welcome! Log In Create A New Profile

Advanced

Re: Location Alias not working

İhsan Doğan
August 28, 2016 01:02PM
Hi,

On Saturday, 27 Aug 2016 21:50 +0100, Francis Daly wrote:

> > I've defined a location alias in my nginx.conf:
>
> > location /foo/ {
> > alias /var/www/foo/;
> > }
>
> > Even the directory /var/www/foo exists, Nginx is returns a 404. As I
> > understand, the configuration is right, but I can't see what's wrong.
>

As requested, I've attached the full configuration file.

> What specific test request do you make?

GET /foo/ with curl:
$ curl https://foo.bar.com/foo/

> What file on the filesystem do you want nginx to return?

UFS (FreeBSD).

> What does your error.log say about the 404 response?

2016/08/28 18:53:32 [error] 22231#0: *11704 open()
"/usr/local/www/foo.bar.com404" failed (2: No such file or
directory), client: 2a02:168:9800::50, server: foo.bar.com,
request: "GET /foo/ HTTP/1.1", host: "foo.bar.com"

> (Is there another location{} block that handles your request, instead
> of the one you showed here?)

Not that I'm aware of.



-Ihsan

--
ihsan@dogan.ch http://blog.dogan.ch/
worker_processes 2;

error_log /var/log/nginx/error.log;

events {
worker_connections 1024;
use kqueue;
}

http {
include mime.types;
default_type application/octet-stream;

sendfile on;
tcp_nopush on;

keepalive_timeout 100;

server_tokens off;

charset UTF-8;

gzip on;
gzip_http_version 1.1;
gzip_vary on;
gzip_comp_level 6;
gzip_proxied any;
gzip_types text/plain text/css application/json application/x-javascript application/xml application/xml+rss text/javascript;
gzip_buffers 4 32k;
gzip_disable "MSIE [1-6].(?!.*SV1)";

client_max_body_size 10G;
large_client_header_buffers 4 32k;

ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # don’t use SSLv3 ref: POODLE
ssl_ciphers ECDH+CHACHA20:ECDH+AESGCM:EDH+AESGCM:ECDH+AES256:ECDH+AES128:EDH+AES:!ADH:!AECDH:!MD5:!DSS;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
ssl_dhparam /usr/local/etc/nginx/dhparam.pem;
ssl_ecdh_curve secp384r1;
ssl_stapling on;
ssl_stapling_verify off;

log_format ssl_custom '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" '
'$gzip_ratio '
'$ssl_protocol:$ssl_cipher';

server {
listen 80;
listen [::]:80;
server_name foo.bar.com;
return 301 https://$server_name$request_uri; # enforce https
}

server {
listen 443 ssl http2;
listen [::]:443 ssl http2;

server_name foo.bar.com;

access_log /var/log/nginx/foo.bar.com/access.log ssl_custom;

ssl_certificate server.crt;
ssl_certificate_key server.key;

root /usr/local/www/foo/bar;

fastcgi_buffers 64 4K;

rewrite ^/caldav(.*)$ /remote.php/caldav$1 redirect;
rewrite ^/carddav(.*)$ /remote.php/carddav$1 redirect;
rewrite ^/webdav(.*)$ /remote.php/webdav$1 redirect;

index index.php index.html;

location = /robots.txt {
allow all;
log_not_found off;
}

location ~ /owncloud/(?:\.htaccess|data|config|db_structure\.xml|README) {
deny all;
}

location ~ ^/usr/local/www/foo.bar.com/(owncloud/)?data {
internal;
root /;
}
location ~ ^/var/tmp/oc-noclean/.+$ {
internal;
root /;
}

location / {
# The following 2 rules are only needed with webfinger
rewrite ^/.well-known/host-meta/public.php?service=host-meta last;
rewrite ^/.well-known/host-meta.json/public.php?service=host-meta-json last;

rewrite ^/.well-known/carddav /remote.php/carddav/ redirect;
rewrite ^/.well-known/caldav /remote.php/caldav/ redirect;
rewrite ^/apps/calendar/caldav.php /remote.php/caldav/ last;
rewrite ^/apps/contacts/carddav.php /remote.php/carddav/ last;
rewrite ^/apps/([^/]*)/(.*\.(css|php))$/index.php?app=$1&getfile=$2 last;

rewrite ^(/core/doc/[^\/]+/)$ $1/index.html;

try_files $uri $uri/ index.php;
}

location ~ /pydio/conf/ { deny all; }
location ~ /pydio/data/ { deny all; }

location ~ ^(.+?\.php)(/.*)?$ {
try_files $1 = 404;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$1;
fastcgi_param PATH_INFO $2;
fastcgi_param HTTPS on;
fastcgi_param MOD_X_ACCEL_REDIRECT_ENABLED on;
fastcgi_read_timeout 3600;
fastcgi_pass unix:/tmp/php-fpm.sock;
}

# Optional: set long EXPIRES header on static assets
location ~* ^.+\.(jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ {
expires 30d;
}

location /mozsync/ {
rewrite ^/mozsync(.+)$ $1 break;
proxy_pass_header Server;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_connect_timeout 10;
proxy_read_timeout 10;
proxy_pass http://unix:/tmp/mozsync.sock;
}

location /chive/ {
try_files $uri chive/$uri/ /chive/index.php?q=$uri&$args;
}

location /foo/ {
alias /var/www/foo/;
}

}
}
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Location Alias not working

İhsan Doğan August 27, 2016 04:40AM

Re: Location Alias not working

Francis Daly August 27, 2016 04:52PM

Re: Location Alias not working

Andrew Holway August 27, 2016 05:20PM

Re: Location Alias not working

Francis Daly August 27, 2016 06:54PM

Re: Location Alias not working

İhsan Doğan August 28, 2016 01:02PM

Re: Location Alias not working

Edho Arief August 28, 2016 01:50PM

Re: Location Alias not working

Francis Daly August 28, 2016 07:20PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 117
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