To create an Nginx location block that serves a website on a subpath of a domain, follow the steps below:
Edit the Nginx configuration file using a text editor:
nano /etc/nginx/nginx.conf
Locate the server block for the domain you want to serve the website on a subpath of.
Create a new location block within the server block:
/subpath/ { }
Replace 'subpath' with the name of the subpath you want to use.
Inside the location block, add the root and index directives:
location /subpath/ {
root /var/www/html/subpath;
index index.html index.htm;
}
Replace '/var/www/html/subpath' with the path to the root directory of the website.
Save the changes to the configuration file and test the configuration:
nginx -t
If the configuration file syntax is correct, reload Nginx to apply the changes:
systemctl reload nginx
Verify that the website is accessible at the subpath:
://example.com/subpath/
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-06-07 06:46:05 +0000
Seen: 12 times
Last updated: Jun 07 '23
How to perform batch geocoding when longitude and latitude values are missing?
How to identify the screen location of the mouse pointer in an electron app?
How can I consolidate divs into a central location?
In what location should the port number be indicated for the SignalR package?
What is the correct location to locate the appropriate Keras layer?
How can I obtain a location image with a marker for free from Google Maps?