This is my /etc/nginx/nginx.conf
:
user nginx;
pid /run/nginx.pid;
worker_processes auto;
error_log /var/log/nginx/error.log error;
worker_rlimit_nofile 10240;
events {
worker_connections 1000;
accept_mutex off; # https://www.nginx.com/blog/thread-pools-boost-performance-9x/
}
http {
aio threads;
types_hash_max_size 4096;
access_log off;
autoindex off;
charset utf-8;
# Timeouts
keepalive_timeout 15;
resolver_timeout 1s;
send_timeout 25;
expires 24h;
client_header_timeout 100;
client_body_timeout 300;
client_max_body_size 20M;
reset_timedout_connection on;
connection_pool_size 256;
add_header Referrer-Policy "origin-when-cross-origin";
add_header Strict-Transport-Security "max-age=63072000; includeSubdomains" always;
sendfile off;
tcp_nopush on;
tcp_nodelay on;
server_tokens off;
server_name_in_redirect off;
server_names_hash_max_size 10240;
server_names_hash_bucket_size 1024;
include mime.types;
default_type application/x-httpd-php;
ignore_invalid_headers on;
index index.php index.htm index.html;
#------------------------------------------------------
# MAIN - mydomain.COM
#------------------------------------------------------
server {
listen 147.182.136.21:80;
server_name .mydomain.com 147.182.136.21;
root /home/mydomain;
index index.htm index.html;
error_page 404 403 /40x.htm;
error_page 500 502 503 504 /50x.htm;
location = /40x.htm { root /home/mydomain; allow all; }
location = /50x.htm { root /home/mydomain; allow all; }
location ~ /. { deny all; }
}
} ## End of overall http block
As seen in the server block, the mydomain.com
stuff should be coming from /home/mydomain
, but I keep getting 404s because according to the logs, Nginx is still looking for files inside the /usr/share/nginx/html/
path.
2024/05/05 03:21:53 [error] 70746#70746: *126 open()
"/usr/share/nginx/html/favicon.ico"
failed (2: No such file or directory),
client: 198.98.120.56, server: localhost,
request: "GET /favicon.ico HTTP/1.1",
host: "3.4.5.6", referrer: "http://3.4.5.6/"
Why is this? How can I force Nginx to look into the path I’ve specified in my nginx.conf?