I have a droplet running nginx on ubuntu 18.04 and have followed this tutorial for setting up a server block: https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-server-blocks-virtual-hosts-on-ubuntu-16-04. So now I have mydomain set up in /var/www/mydomain/ with an html folder and index.html file that works perfectly fine. But now I want to be able to deploy static pages built from react. So I created a folder called /projects/ in /var/www/mydomain/ and then placed the production build within. Now I go into the /etc/nginx/sites-available/mydomain and add location /projectName { root /var/www/mydomain/projects/projects/build; try_files $uri /index.html; } but this never seems to work. When I navigate to mydomain.com/projectName I’m always either taken to the home page, given a 403 or 404 error, or sometimes it does successfully serve me the proper project index.html but the page does not render as if the javascript is not compiling properly. The build is just a static page with its own resources so I know I don’t need to start a pm2 process, its just a matter of having nginx route the location to the build folder properly, but I can’t get it to work. Thank you the help.
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!
Hello,
I think that this might be a problem with your file permissions, what I could suggest is following the steps here on how to troubleshoot common Nginx problems:
Regards, Bobby
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.