Trying to understand why this new installation of nginx is not serving any files at all. I have a minimal website configuration. (rtmp was working last I checked but that has not been needed in a while. Just added the port 80 configuration. I mention only because you'll see it in the config.)
When I try to access this host (by IP or by hostname), I get a "403 (forbidden)" error"displayed on the web page, and nothing at all in the /var/log/nginx/error.log file. (That file has zero bytes, even after reboot and retry.)
All the other questions I've found like this on serverfault, have help in the error.log file. Since error.log is empty, I've created this new question.
This happens when I try to use the default index facility, and when I try specific files, such as these examples:
http://hpmicro1
http://hpmicro1.innerdomain.com
http://hpmicro1.innerdomain.com/index.html
http://192.168.1.5
http://192.168.1.5/index.html
http://192.168.1.5/index.php
and so on. As you can see, those files exist, and are owned by www-data:
# ls -l /www/htdocs
total 60
-rw-rw-rw- 1 www-data www-data 35752 Jul 17 14:09 dbg-wizard.php
drwxrwxr-x 2 www-data www-data 4096 Jul 16 08:15 functions
drwxrwxr-x 2 www-data www-data 4096 Jul 17 12:38 GetChats
-rw-r--r-- 1 www-data www-data 10918 Jul 18 16:16 index.html
-rw-rw-rw- 1 www-data www-data 20 Jul 17 14:18 index.php
# ls -ld /www/htdocs
drwxrwxr-x 5 www-data dennis 4096 Jul 18 16:22 /www/htdocs
Here is the /etc/nginx/nginx.conf file content:
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 TLSv1.3;
ssl_prefer_server_ciphers on;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
rtmp {
server {
listen 1935;
chunk_size 4096;
notify_method get;
application WendellLive {
on_publish http://localhost/auth;
live on;
record off;
record_path /svr/rtmp-recordings;
record_unique on;
push rtmp://localhost/Wendell_YT;
}
application Wendell_YT {
live on;
record off;
allow publish 127.0.0.1;
deny publish all;
push rtmp://a.rtmp.youtube.com/live2/<wendell_yt_stream_key>;
}
}
}
And the /etc/nginx/sites-enabled/default configuration
server {
listen 80 default_server;
listen [::]:80 default_server;
root /www/htdocs;
index index.php index.html index.htm index.nginx-debian.html;
server_name home.lovelady.com;
location / {
try_files $uri $uri/ =404;
}
location /auth {
if ($arg_pwd = 'my_secret_not_yours') {
return 200;
}
return 401;
}
}
Version information:
nginx version: nginx/1.18.0 (Ubuntu)
>>> cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.2 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.2 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
The content of /var/log/nginx is:
# ls -ltr /var/log/nginx/
total 72
-rw-r
-rw-r
-rw-r
-rw-r
-rw-r
-rw-r
-rw-r
-rw-r
-rw-r
-rw-r
-rw-r
-rw-r
-rw-r
-rw-r
-rw-r
-rw-r
-rw-r
-rw-r
-rw-r
access.log has this one line:
# cat /var/log/nginx/access.log
192.168.1.203 - - [18/Jul/2021:16:07:37 -0400] "GET / HTTP/1.1" 200 20 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"
Output of nginx -T upon request:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
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 TLSv1.3;
ssl_prefer_server_ciphers on;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
rtmp {
server {
listen 1935;
chunk_size 4096;
notify_method get;
application love-uav {
on_publish http://localhost/auth;
live on;
record off;
record_path /svr/rtmp-recordings;
record_unique on;
push rtmp://localhost/love-uav_YT;
}
application love-uav_YT {
live on;
record off;
allow publish 127.0.0.1;
deny publish all;
push rtmp://a.rtmp.youtube.com/live2/jsqu-54jv-uw68-39tf-xxxx;
}
application love-uav_Twitch {
live on;
record off;
allow publish 127.0.0.1;
deny publish all;
push rtmp://live-cdg.twitch.tv/app/<love-uav__twitch_stream_key>;
}
application love-uav_Facebook {
live on;
record off;
allow publish 127.0.0.1;
deny publish all;
}
application WendellLive {
on_publish http://localhost/auth;
live on;
record off;
record_path /svr/rtmp-recordings;
record_unique on;
push rtmp://localhost/Wendell_YT;
}
application Wendell_YT {
live on;
record off;
allow publish 127.0.0.1;
deny publish all;
push rtmp://a.rtmp.youtube.com/live2/<wendell_yt_stream_key>;
}
}
}
load_module modules/ngx_http_image_filter_module.so;
load_module modules/ngx_http_xslt_filter_module.so;
load_module modules/ngx_mail_module.so;
load_module modules/ngx_rtmp_module.so;
load_module modules/ngx_stream_module.so;
types {
text/html html htm shtml;
text/css css;
text/xml xml;
image/gif gif;
image/jpeg jpeg jpg;
application/javascript js;
application/atom+xml atom;
application/rss+xml rss;
text/mathml mml;
text/plain txt;
text/vnd.sun.j2me.app-descriptor jad;
text/vnd.wap.wml wml;
text/x-component htc;
image/png png;
image/tiff tif tiff;
image/vnd.wap.wbmp wbmp;
image/x-icon ico;
image/x-jng jng;
image/x-ms-bmp bmp;
image/svg+xml svg svgz;
image/webp webp;
application/font-woff woff;
application/java-archive jar war ear;
application/json json;
application/mac-binhex40 hqx;
application/msword doc;
application/pdf pdf;
application/postscript ps eps ai;
application/rtf rtf;
application/vnd.apple.mpegurl m3u8;
application/vnd.ms-excel xls;
application/vnd.ms-fontobject eot;
application/vnd.ms-powerpoint ppt;
application/vnd.wap.wmlc wmlc;
application/vnd.google-earth.kml+xml kml;
application/vnd.google-earth.kmz kmz;
application/x-7z-compressed 7z;
application/x-cocoa cco;
application/x-java-archive-diff jardiff;
application/x-java-jnlp-file jnlp;
application/x-makeself run;
application/x-perl pl pm;
application/x-pilot prc pdb;
application/x-rar-compressed rar;
application/x-redhat-package-manager rpm;
application/x-sea sea;
application/x-shockwave-flash swf;
application/x-stuffit sit;
application/x-tcl tcl tk;
application/x-x509-ca-cert der pem crt;
application/x-xpinstall xpi;
application/xhtml+xml xhtml;
application/xspf+xml xspf;
application/zip zip;
application/octet-stream bin exe dll;
application/octet-stream deb;
application/octet-stream dmg;
application/octet-stream iso img;
application/octet-stream msi msp msm;
application/vnd.openxmlformats-officedocument.wordprocessingml.document docx;
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx;
application/vnd.openxmlformats-officedocument.presentationml.presentation pptx;
audio/midi mid midi kar;
audio/mpeg mp3;
audio/ogg ogg;
audio/x-m4a m4a;
audio/x-realaudio ra;
video/3gpp 3gpp 3gp;
video/mp2t ts;
video/mp4 mp4;
video/mpeg mpeg mpg;
video/quicktime mov;
video/webm webm;
video/x-flv flv;
video/x-m4v m4v;
video/x-mng mng;
video/x-ms-asf asx asf;
video/x-ms-wmv wmv;
video/x-msvideo avi;
}
server {
listen 80 default_server;
listen [::]:80 default_server;
root /www/htdocs;
index index.php index.html index.htm index.nginx-debian.html;
server_name home.lovelady.com;
location / {
try_files $uri $uri/ =404;
}
location /auth {
if ($arg_pwd = 'my_secret_not_yours') {
return 200;
}
return 401;
}
}
Failure: 