I am trying to modify my drupal droplet nginx configuration to serve files from an another location.
/var/www/html/mysite <-- already configured and works fine and is accessible through the webserver
/var/www/html/resources <-- I want to configure the webserver to serve content from this directory
The modification I made in /etc/nginx/sites-available/drupal is not taking effect
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /var/www/html/mysite;
index index.php index.html index.htm;
.
.
.
location ~* ^/more/ {
root /var/www/html/resources;
index index.html index.htm;
try_files $uri $uri/ =404;
}
}
Still resources served from under the /resources is throwing 404 for e.g. http://cfcindia.org/resources/en/books/pdf/AGF.pdf
what is the nginx configuration changes to serve files from /resources?
I am an nginx newbie, and have researched existing community questions, and the internet, but could not get it to work. HELP!
Rabi
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Because of the way nginx handles the root directive, it would try to serve /var/www/html/resources/more/en/books/pdf/AGF.pdf when you browsed to http://cfcindia.org/more/en/books/pdf/AGF.pdf. Replace it with alias and you should be good to go:
location /more {
alias /var/www/html/resources;
index index.html index.htm;
}
Don’t forget to restart nginx so that the changes take effect:
sudo service nginx restart
Hi Kamain7,
Thanks for the suggestion, and it makes sense.
However replacing in my nginx conf as below still does not work
server { listen 80 default_server; listen [::]:80 default_server ipv6only=on;
root /var/www/html/mysite; index index.php index.html index.htm; . . . location /more { alias /var/www/html/resources; index index.html index.htm; }
I did restart nginx as you suggested.
Suggestions?
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.