How to configure a static resource folder in Nginx?
To set up a static resource folder, you first need to open the nginx configuration file. By default, the nginx configuration file is located at /etc/nginx/nginx.conf or /usr/local/nginx/conf/nginx.conf.
Locate the server block in the configuration file, and then add the following settings within it.
server {
listen 80;
server_name your_domain.com;
root /path/to/your/static/files;
location / {
try_files $uri $uri/ =404;
}
}
In the configuration above, you should replace “your_domain.com” with your own domain, and replace “/path/to/your/static/files” with the path to your static resource folder.
After configuring, save the file and restart the nginx service to make the configuration take effect. You can use the following command to restart the nginx service:
sudo systemctl reload nginx