Welcome! Log In Create A New Profile

Advanced

location root not working as described

John Fowler
March 20, 2021 06:10PM
Good Day,
Thank you for your suggestion, but I had tried using the alias as well and that did not work as advertised. The following is the results of using the alias and “^~”.

I do see some odd behavior.

The following access snippet
2021/03/20 21:44:21 [error] 14#14: *7 open() "/var/www/certbottest.html" failed (2: No such file or directory), client: 10.0.0.2, server: cyva.lese-fowler.us, request: "GET /.well-known/acme-challenge/test.html HTTP/1.1", host: "cyva.lese-fowler.us"
2021/03/20 21:44:37 [error] 14#14: *5 open() "/var/www/certbotindex.html" failed (2: No such file or directory), client: 10.0.0.2, server: cyva.lese-fowler.us, request: "GET /.well-known/acme-challenge/index.html HTTP/1.1", host: "cyva.lese-fowler.us"
aligns to the error log entries of
2021/03/20 21:44:21 [error] 14#14: *7 open() "/var/www/certbottest.html" failed (2: No such file or directory), client: 10.0.0.2, server: cyva.lese-fowler.us, request: "GET /.well-known/acme-challenge/test.html HTTP/1.1", host: "cyva.lese-fowler.us"
2021/03/20 21:44:37 [error] 14#14: *5 open() "/var/www/certbotindex.html" failed (2: No such file or directory), client: 10.0.0.2, server: cyva.lese-fowler.us, request: "GET /.well-known/acme-challenge/index.html HTTP/1.1", host: "cyva.lese-fowler.us"

But I don’t know where the certbottest.html is coming from…

Still based on what I have read, I would expect that the /var/www/certbot/index.html should be visible via the URL of /.well-known/acme-challenge/index.html


The larger segments of Error log & Access Logs

2021/03/20 21:18:11 [notice] 12#12: using the "epoll" event method
2021/03/20 21:18:11 [notice] 12#12: nginx/1.19.5
2021/03/20 21:18:11 [notice] 12#12: built by gcc 8.3.0 (Raspbian 8.3.0-6+rpi1)
2021/03/20 21:18:11 [notice] 12#12: OS: Linux 5.10.17-v7+
2021/03/20 21:18:11 [notice] 12#12: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2021/03/20 21:18:11 [notice] 13#13: start worker processes
2021/03/20 21:18:11 [notice] 13#13: start worker process 14
2021/03/20 21:29:02 [info] 14#14: *1 client 10.0.0.2 closed keepalive connection
2021/03/20 21:38:04 [warn] 14#14: no resolver defined to resolve r3.o.lencr.org while requesting certificate status, responder: r3.o.lencr.org, certificate: "/etc/letsencrypt/live/cyva.lese-fowler.us/fullchain.pem"
2021/03/20 21:38:43 [error] 14#14: *2 open() "/var/www/certbottest.html" failed (2: No such file or directory), client: 10.0.0.2, server: cyva.lese-fowler.us, request: "GET /.well-known/acme-challenge/test.html HTTP/1.1", host: "cyva.lese-fowler.us"
2021/03/20 21:38:54 [error] 14#14: *2 open() "/var/www/certbotindex.html" failed (2: No such file or directory), client: 10.0.0.2, server: cyva.lese-fowler.us, request: "GET /.well-known/acme-challenge/index.html HTTP/1.1", host: "cyva.lese-fowler.us"
2021/03/20 21:38:55 [error] 14#14: *2 open() "/var/www/certbotindex.html" failed (2: No such file or directory), client: 10.0.0.2, server: cyva.lese-fowler.us, request: "GET /.well-known/acme-challenge/index.html HTTP/1.1", host: "cyva.lese-fowler.us"
2021/03/20 21:39:32 [info] 14#14: *4 client 10.0.0.2 closed keepalive connection
2021/03/20 21:39:34 [info] 14#14: *2 client 10.0.0.2 closed keepalive connection
2021/03/20 21:43:07 [error] 14#14: *6 open() "/var/www/certbottest.html" failed (2: No such file or directory), client: 10.0.0.2, server: cyva.lese-fowler.us, request: "GET /.well-known/acme-challenge/test.html HTTP/1.1", host: "cyva.lese-fowler.us"
2021/03/20 21:43:08 [error] 14#14: *5 open() "/var/www/certbottest2.html" failed (2: No such file or directory), client: 10.0.0.2, server: cyva.lese-fowler.us, request: "GET /.well-known/acme-challenge/test2.html HTTP/1.1", host: "cyva.lese-fowler.us"
2021/03/20 21:43:10 [error] 14#14: *5 open() "/var/www/certbottest2.html" failed (2: No such file or directory), client: 10.0.0.2, server: cyva.lese-fowler.us, request: "GET /.well-known/acme-challenge/test2.html HTTP/1.1", host: "cyva.lese-fowler.us"
2021/03/20 21:43:52 [error] 14#14: *5 open() "/var/www/certbottest.html" failed (2: No such file or directory), client: 10.0.0.2, server: cyva.lese-fowler.us, request: "GET /.well-known/acme-challenge/test.html HTTP/1.1", host: "cyva.lese-fowler.us"
2021/03/20 21:44:07 [info] 14#14: *6 client 10.0.0.2 closed keepalive connection
2021/03/20 21:44:15 [error] 14#14: *5 open() "/var/www/certbottest.html" failed (2: No such file or directory), client: 10.0.0.2, server: cyva.lese-fowler.us, request: "GET /.well-known/acme-challenge/test.html HTTP/1.1", host: "cyva.lese-fowler.us"
2021/03/20 21:44:21 [error] 14#14: *7 open() "/var/www/certbottest.html" failed (2: No such file or directory), client: 10.0.0.2, server: cyva.lese-fowler.us, request: "GET /.well-known/acme-challenge/test.html HTTP/1.1", host: "cyva.lese-fowler.us"
2021/03/20 21:44:37 [error] 14#14: *5 open() "/var/www/certbotindex.html" failed (2: No such file or directory), client: 10.0.0.2, server: cyva.lese-fowler.us, request: "GET /.well-known/acme-challenge/index.html HTTP/1.1", host: "cyva.lese-fowler.us"
2021/03/20 21:44:58 [error] 14#14: *5 open() "/var/www/certbottest.html" failed (2: No such file or directory), client: 10.0.0.2, server: cyva.lese-fowler.us, request: "GET /.well-known/acme-challenge/test.html HTTP/1.1", host: "cyva.lese-fowler.us"
2021/03/20 21:45:00 [error] 14#14: *5 open() "/var/www/certbottest2.html" failed (2: No such file or directory), client: 10.0.0.2, server: cyva.lese-fowler.us, request: "GET /.well-known/acme-challenge/test2.html HTTP/1.1", host: "cyva.lese-fowler.us"
2021/03/20 21:45:20 [info] 14#14: *7 client 10.0.0.2 closed keepalive connection
2021/03/20 21:45:37 [info] 14#14: *5 client 10.0.0.2 closed keepalive connection
2021/03/20 21:50:17 [error] 14#14: *9 open() "/var/www/html/robots.txt" failed (2: No such file or directory), client: 10.0.0.2, server: cyva.lese-fowler.us, request: "GET /robots.txt HTTP/1.1", host: "cyva.lese-fowler.us"
2021/03/20 21:50:17 [info] 14#14: *8 client 10.0.0.2 closed keepalive connection
2021/03/20 21:50:17 [info] 14#14: *9 client 10.0.0.2 closed keepalive connection
2021/03/20 21:50:19 [info] 14#14: *10 client 10.0.0.2 closed keepalive connection
2021/03/20 21:52:07 [info] 14#14: *11 client closed connection while waiting for request, client: 10.0.0.2, server: 0.0.0.0:80
root@ebd348cda0e9:~#


10.0.0.2 - - [20/Mar/2021:21:43:52 +0000] "GET /.well-known/acme-challenge/test.html HTTP/1.1" 404 153 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Safari/605.1.15" "-"
10.0.0.2 - - [20/Mar/2021:21:44:01 +0000] "GET /web/patches.html HTTP/1.1" 200 1476 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Safari/605.1.15" "-"
10.0.0.2 - - [20/Mar/2021:21:44:15 +0000] "GET /.well-known/acme-challenge/test.html HTTP/1.1" 404 153 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Safari/605.1.15" "-"
10.0.0.2 - - [20/Mar/2021:21:44:21 +0000] "GET /.well-known/acme-challenge/test.html HTTP/1.1" 404 153 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Safari/605.1.15" "-"
10.0.0.2 - - [20/Mar/2021:21:44:37 +0000] "GET /.well-known/acme-challenge/index.html HTTP/1.1" 404 153 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Safari/605.1.15" "-"
10.0.0.2 - - [20/Mar/2021:21:44:58 +0000] "GET /.well-known/acme-challenge/test.html HTTP/1.1" 404 153 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Safari/605.1.15" "-"
10.0.0.2 - - [20/Mar/2021:21:45:00 +0000] "GET /.well-known/acme-challenge/test2.html HTTP/1.1" 404 153 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Safari/605.1.15" "-"
10.0.0.2 - - [20/Mar/2021:21:50:17 +0000] "GET /robots.txt HTTP/1.1" 404 153 "-" "Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)" "-"
root@ebd348cda0e9:~#


The following is the view from within the docker container running nginx


root@ebd348cda0e9:~# fg
tail -f /var/log/nginx/error.log
^C
root@ebd348cda0e9:~# fg
tail -f /var/log/nginx/access.log
^C
root@ebd348cda0e9:~#
root@ebd348cda0e9:~# ls -la /var/www/html
total 42088
drwxrwxrwx 9 1000 1000 4096 Mar 20 21:28 .
drwxr-xr-x 1 root root 4096 Feb 12 00:52 ..
drwxrwxrwx 3 1000 1000 4096 Mar 3 2020 ANA630
drwxrwxrwx 2 1000 1000 4096 Mar 3 2020 ANA660
drwxrwxrwx 3 1000 1000 4096 Jul 24 2020 CYVA
drwxrwxrwx 2 1000 1000 4096 Mar 3 2020 Patches
-rw-r--r-- 1 1000 1000 4291 Jan 21 2019 Pi-Root-Index.html
-rw-r--r-- 1 1000 1000 3253523 Jan 29 2018 Pi-Root-Index_html_407e10bad835ca36.jpg
-rw-r--r-- 1 1000 1000 17632732 Jan 29 2018 Pi-Root-Index_html_549480d9aaa04db.jpg
-rw-r--r-- 1 1000 1000 13986083 Jan 29 2018 Pi-Root-Index_html_6a0daedaa917b2c9.jpg
-rw-r--r-- 1 1000 1000 1652156 Jan 29 2018 Pi-Root-Index_html_7150c5fe82705e6d.jpg
-rw-r--r-- 1 1000 1000 6334055 Jan 29 2018 Pi-Root-Index_html_97f9e5219c289a82.jpg
-rw-r--r-- 1 1000 1000 84524 Jan 29 2018 Pi-Root-Index_html_dad3680972715349.jpg
drwxrwxrwx 3 1000 1000 4096 Mar 1 02:39 Test
-rw-rw-r-- 1 1000 1000 318 Feb 8 2019 favicon.ico
-rw-r--r-- 1 1000 1000 4394 Feb 13 23:04 index.html
drwxr-xr-x 2 1000 1000 4096 Feb 16 02:45 info
-rw-r--r-- 1 1000 1000 10701 Jan 29 2018 original.html
drwxr-sr-x 2 1000 1000 4096 Mar 18 03:34 web
root@ebd348cda0e9:~# ls -lRa /var/www/certbot/
/var/www/certbot/:
total 24
drwxr-xr-x 2 root root 4096 Mar 18 04:06 .
drwxr-xr-x 1 root root 4096 Feb 12 00:52 ..
-rw-r--r-- 1 root root 1727 Mar 18 03:22 index.html
-rw-r--r-- 1 root root 1531 Mar 18 03:23 test.html
-rw-r--r-- 1 root root 1533 Mar 9 02:59 test2.html
root@ebd348cda0e9:~# df -h
Filesystem Size Used Avail Use% Mounted on
overlay 28G 9.1G 17G 35% /
tmpfs 64M 0 64M 0% /dev
tmpfs 461M 0 461M 0% /sys/fs/cgroup
shm 64M 0 64M 0% /dev/shm
coolwave.lese-fowler.us:/volume1/homes/pi/nginx/certbot/conf 1.8T 1.2T 687G 63% /etc/letsencrypt
/dev/root 28G 9.1G 17G 35% /etc/hosts
coolwave.lese-fowler.us:/volume1/homes/pi/www 1.8T 1.2T 687G 63% /var/www/html
coolwave.lese-fowler.us:/volume1/homes/pi/nginx/logs 1.8T 1.2T 687G 63% /var/log/nginx
coolwave.lese-fowler.us:/volume1/homes/pi/nginx/conf 1.8T 1.2T 687G 63% /etc/nginx/conf
coolwave.lese-fowler.us:/volume1/homes/pi/nginx/certbot/www 1.8T 1.2T 687G 63% /var/www/certbot
coolwave.lese-fowler.us:/volume1/homes/pi/nginx/logs 1.8T 1.2T 687G 63% /usr/share/nginx/logs
tmpfs 461M 0 461M 0% /proc/asound
tmpfs 461M 0 461M 0% /sys/firmware



***** NGINX.CONF


root@ebd348cda0e9:~# cat /etc/nginx/conf/nginx.conf
# Configuration File Provided by CYVA Research
# Designed to host port 80 & 443 for web viewing
# port 8080 is configured to pass traffic to pi3.lese-fowler.us
# port 1883 and 8883 are configured to pass tcp streams to
# pi3.lese-fowler.us as well.
# load_module modules/nginx-plus-module-headers-more
# load_module modules/nginx-plus-module-set-misc
# load_module modules/ngx_stream_proxy_module
load_module /etc/nginx/modules/ngx_stream_module.so;
#
# configuration file /etc/nginx/nginx.conf:
#user nobody;
worker_processes 1;

# error_log /var/log/nginx/error.log debug;
error_log /var/log/nginx/error.log debug;
#error_log /var/log/nginx/error.log notice;
#error_log /var/log/nginx/error.log info;
#pid /var/log/nginx/nginx.pid;
events {
worker_connections 1024;
}
#
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
#
# sendfile on;
# tcp_nopush on;
# keepalive_timeout 65;
#
set_real_ip_from 10.0.0.0/16;
set_real_ip_from 172.16.0.0/24;
set_real_ip_from 192.168.0.0/24;
real_ip_header X-Real-IP;
#
server {
# Add headers to serve security related headers
# Before enabling Strict-Transport-Security headers please read into this
# topic first.
#add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;" always;
#
# WARNING: Only add the preload option once you read about
# the consequences in https://hstspreload.org/. This option
# will add the domain to a hardcoded list that is shipped
# in all major browsers and getting removed from this list
# could take several months.
add_header Referrer-Policy "no-referrer" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-Download-Options "noopen" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Permitted-Cross-Domain-Policies "none" always;
add_header X-Robots-Tag "none" always;
add_header X-XSS-Protection "1; mode=block" always;
# add_header cache-control: public, max-age=120;
# Remove X-Powered-By, which is an information leak
fastcgi_hide_header X-Powered-By;

listen 80;
server_name cyva.lese-fowler.us 172.16.10.30;
access_log /var/log/nginx/cyva.access.log main;
root /var/www/html;
# location ^~ /.well-known/acme-challenge {
# location ^~ /.well-known/ {
# allow all;
# }
# alias vs root
location ^~ /.well-known/acme-challenge/ {
allow all;
alias /var/www/certbot;
try_files $uri =405;
}
location / {
allow all;
}

location = /robots.txt {
allow all;
log_not_found on;
access_log on;
}
# serve static files
# location ~ ^/(images|javascript|js|css|flash|media|static)/ {
#location ~* / {
# alias /var/www/html;
# expires 30d;
#}
# redirect http to https www
return 301 https://cyva.lese-fowler.us$request_uri;
# Enable gzip but do not remove ETag headers
gzip on;
gzip_vary on;
gzip_comp_level 4;
gzip_min_length 256;
gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy;
#
# Uncomment if your server is build with the ngx_pagespeed module
# This module is currently not supported.
#pagespeed off;
#
# location / {
# rewrite ^ /index.html;
#}

location ~ ^\/(?:build|tests|config|lib|3rdparty|templates|data)\/ {
deny all;
}
location ~ ^\/(?:\.|autotest|occ|issue|indie|db_|console) {
deny all;
}
#
}

server { # http2
listen [::]:443 ssl;
listen 443 ssl;
server_name cyva.lese-fowler.us 172.16.10.30;
root /var/www/html;

# SSL code
ssl_certificate /etc/letsencrypt/live/cyva.lese-fowler.us/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/cyva.lese-fowler.us/privkey.pem;

ssl_session_timeout 1d;
ssl_session_cache shared:SharedNixCraftSSL:10m;
ssl_session_tickets off;

# TLS 1.2 & 1.3 only
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;

ssl_ciphers "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH+aRSA+RC4 EECDH EDH+aRSA RC4 !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS";

# HSTS (ngx_http_headers_module is required) (63072000 seconds)
add_header Strict-Transport-Security "max-age=63072000" always;

# OCSP stapling
ssl_stapling on;
ssl_stapling_verify on;

# location ~ /.well-known {
# allow all;
# }
# verify chain of trust of OCSP response using Root CA and Intermediate certs
# ssl_trusted_certificate /etc/nginx/ssl/fullchain.pem;
# location ^~ /.well-known/acme-challenge/ {
# location ^~ /.well-known/ {
location ^~ /.well-known/acme-challenge/ {
allow all;
alias /var/www/certbot;
}
location / {
allow all;
index index.html;
}
}

# simple reverse-proxy
server {
listen 8080;
server_name cyva.lese-fowler.us 172.16.10.30;
access_log /var/log/nginx/reverse.access.log main;
# serve static files
location /
{
proxy_pass https://pi3.lese-fowler.us:80;
}
}
} # End of html block
# ***********************
# The following code is not permitted until we find the correct nginx code
#
stream {
log_format st-main '$remote_addr - [$time_local] $status $bytes_sent ';
server {
listen 8084;
access_log /var/log/nginx/mqtt-non.log st-main;
#TCP traffic will be forwarded to the "stream_backend" upstream group
proxy_pass cyva.lese-fowler.us:1883;
}
#
server {
listen 8085;
access_log /var/log/nginx/mqtt.log st-main;
#TCP traffic will be forwarded to the specified server
proxy_pass cyva.lese-fowler.us:8883;
}
}
#root@ebd348cda0e9:~# _______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

location root not working as described

John Fowler March 20, 2021 06:10PM

Re: location root not working as described

Francis Daly March 20, 2021 08:16PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 54
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready