By deeperdata
I’m running Nginx on CentOS. My primary site is running as it should be on the site - no issues there. However, I’ve created a demo site for a client and I am running it in a sub-directory under mydomain.com/sites/clientsite/ and see the PHP/HTML no problem but anything related to images, CSS or JS is having the full root server path inserted before it (e.g. mydomain.com/usr/share/nginx/html/sites/clientsite/bg.jpg). I’m certain this is related to Nginx configuration file but I’ve modified it several times and restarted with no luck. Has anyone else run into this issue?
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!
Please pastebin your nginx config, is your app generating the asset links or are they hardcoded in?
I thought the same about the hardcoding but it is only happening on my staging server here at Digital Ocean and not on the production environment. Here is my default.conf: <br> <br># <br># The default server <br># <br>server { <br> listen 80; <br> server_name mydomain.com; <br> <br> <br> location / { <br> root /usr/share/nginx/html; <br> index index.php index.html index.htm; <br> } <br> <br> error_page 404 /404.html; <br> location = /404.html { <br> root /usr/share/nginx/html; <br> } <br> <br> error_page 500 502 503 504 /50x.html; <br> location = /50x.html { <br> root /usr/share/nginx/html; <br> } <br> <br> # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 <br> # <br> location ~ .php$ { <br> root /usr/share/nginx/html; <br> fastcgi_pass 127.0.0.1:9000; <br> fastcgi_index index.php; <br> fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; <br> include fastcgi_params; <br> } <br>} <br> <br>_______________ <br> <br>I assumed it was the “root /usr/share/nginx/html” towards the end but after commenting it out, it still does the same thing. Here is my virtual.conf (ip has been changed for anonymity): <br> <br>_______________ <br># <br># A virtual host using mix of IP-, name-, and port-based configuration <br># <br> <br>server { <br> # listen 80; <br> listen 12.34.55.78:80; <br> server_name mydomain.com www.mydomain.com; <br> <br> location / { <br> root /usr/share/nginx/html/; <br> index index.php index.html index.htm; <br> <br> <br>#location ~* .(jpg|jpeg|png|gif|ico|css|js)$ { <br># expires 365d; <br> <br>#} <br> <br>location ~ .php$ { <br>fastcgi_pass 127.0.0.1:9000; <br>fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; <br>include fastcgi_params; <br>} <br> <br> } <br>} <br>
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.