Serving a subdirectory
Thomas Schweikle
tschweikle at gmail.com
Fri Dec 6 11:39:59 UTC 2019
Configuration
/etc/nginx/sites-available:
chrony
default
/etc/nginx/sites-available/chrony:
server {
listen 443 default_server ssl;
listen [::]:443 default_server ssl;
server_name <server fqdn>;
root /var/www/chrony;
index index.sh index.html;
location /chrony {
try_files $uri $uri/ $uri/index.sh;
}
location ~ "index\.sh"$ {
gzip off;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
include /etc/nginx/fastcgi_params;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SCRIPT_FILENAME $request_filename;
}
}
/etc/nginx/sites-available/default:
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
try_files $uri $uri/ =404;
}
}
/etc/nginx/nginx.conf:
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
}
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
gzip_disable "msie6";
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
Filesystem:
/var/www/html/index.nginx-debian.html
/var/www/chrony/index.sh
/var/www/chrony/chrony.css
For https://<fqdn-server>/:
nginx default site delivered ok.
For https://<fqdn-server>/chrony:
404 - Not found.
Versions:
ii fcgiwrap 1.1.0-9
armhf simple server to run CGI applications over FastCGI
ii libfcgi-bin 2.4.0-8.4
armhf FastCGI bridge from CGI
ii libfcgi0ldbl:armhf 2.4.0-8.4
armhf Shared library of FastCGI
ii libnginx-mod-http-auth-pam 1.10.3-1+deb9u3
armhf PAM authentication module for Nginx
ii libnginx-mod-http-dav-ext 1.10.3-1+deb9u3
armhf WebDAV missing commands support for Nginx
ii libnginx-mod-http-echo 1.10.3-1+deb9u3
armhf Bring echo and more shell style goodies to Nginx
ii libnginx-mod-http-geoip 1.10.3-1+deb9u3
armhf GeoIP HTTP module for Nginx
ii libnginx-mod-http-image-filter 1.10.3-1+deb9u3
armhf HTTP image filter module for Nginx
ii libnginx-mod-http-subs-filter 1.10.3-1+deb9u3
armhf Substitution filter module for Nginx
ii libnginx-mod-http-upstream-fair 1.10.3-1+deb9u3
armhf Nginx Upstream Fair Proxy Load Balancer
ii libnginx-mod-http-xslt-filter 1.10.3-1+deb9u3
armhf XSLT Transformation module for Nginx
ii libnginx-mod-mail 1.10.3-1+deb9u3
armhf Mail module for Nginx
ii libnginx-mod-stream 1.10.3-1+deb9u3
armhf Stream module for Nginx
ii nginx 1.10.3-1+deb9u3
all small, powerful, scalable web/proxy server
ii nginx-common 1.10.3-1+deb9u3
all small, powerful, scalable web/proxy server - common files
ii nginx-full 1.10.3-1+deb9u3
armhf nginx web/proxy server (standard version)
On Thu, Dec 5, 2019 at 4:02 PM Francis Daly <francis at daoine.org> wrote:
> On Wed, Dec 04, 2019 at 07:08:52PM +0100, Thomas Schweikle wrote:
>
> Hi there,
>
> > I'm a little bit lost now, since various configurations tried just dont
> > work. None of them.
>
> I'm not quite clear on what specifically you want your nginx to do.
>
> If it matters -- could you describe that?
>
> > location /chrony {
> > try_files $uri $uri/ $uri/ index.sh;
> > }
> >
> > location ~ "index\.sh"$ {
>
> I suspect that some of this was re-typed from the config, rather than
> having been copy-pasted.
>
> The "$ probably should be $"; and I'm not sure if the space before
> the index.sh is intended or not.
>
> > fastcgi_param SCRIPT_FILENAME $request_filename;
>
> For testing, you could try to put
>
> return 200 "in index.sh - $request_filename\n";
>
> in this location{}. It will *not* invoke fastcgi, but it will show you
> want filename nginx writes in the matching variable.
>
> > If i am looking at the debug logs all seems OK: nginx feeds
> > /var/www/chrony/index.sh to fcgiwraper. /var/www/chrony/index.sh is
> allowed
> > to be executed by all. group is root, owner is root. Only the owner is
> > allowed to write the file. All others are allowed to execute it.
>
> I do not know if it is the same version that you are using, but the
> code at https://github.com/gnosek/fcgiwrap/blob/master/fcgiwrap.c looks
> like it includes a "reason" message with a 403 code. That message might
> indicate why the system thinks there is a problem.
>
> > My first question: why doesn't nginx:
>
> If you can show the config you are using, it may be clear why nginx does
> what it does.
>
> If what you want is "serve dir/index.sh when the request is for dir/",
> then it might be enough to remove the try_files block, and fix the
> index.sh line.
>
> Good luck with it,
>
> f
> --
> Francis Daly francis at daoine.org
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
--
Thomas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20191206/05e2cf30/attachment-0001.htm>
More information about the nginx
mailing list