I have Nginx 1.18.0 installed on Ubuntu 20.04. I am trying to serve (many) custom HTML files via Nginx. The HTML files contain animation of online images and mapping. Some HTML files also have associated JS and CSS files.
Instead of using defaults, I created a server block my_domain
like this:
mkdir -p /var/www/my_domain/html
chown -R my_username /var/www/my_domain/html
chmod -R 755 /var/www/my_domain
ln -s /etc/nginx/sites-available/my_domain /etc/nginx/sites-enabled/
Then, as a test, I put my_html1.html
(here, no associated JS/CSS) inside /var/www/my_domain/html
and tried to access via Mozilla Firefox browser. I am getting 403 Error Forbidden
.
I googled the error and tried suggestions provided here, but so far, no success. For example, I tried assigning the ownership of my_domain
directory to www-data user, but didn't help.
chown -R www-data:www-data /etc/nginx/sites-available/my_domain
This is how my nginx.conf
look like.
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;
server_names_hash_bucket_size 64;
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
and /etc/nginx/sites-available/my_domain
server {
listen 80;
root /var/www/my_domain/html;
index my_html1.html;
server_name my_domain www.my_domain;
location / {
try_files $uri $uri/ =404;
autoindex on;
autoindex_exact_size off;
}
}
Can somebody help me to fix this issue?