Welcome! Log In Create A New Profile

Advanced

location root not working as described

John Fowler
March 20, 2021 08:36PM
Thank you for the pointer.

Looks like the problem has been resolved. The location needed a trailing “/“ on the path.

location ^~ /.well-known/acme-challenge/ {
allow all;
alias /var/www/certbot/;
try_files $uri =405;
}



John


Working Niginx.conf

root@f6c5686e1968:/# 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@f6c5686e1968:/#_______________________________________________
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 08:36PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

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