Forum OpenACS Q&A: NGINX and CSS files

Collapse
Posted by Iuri Sampaio on
Hi there,

After installing OACS together with NGINX with a small difference from standard installation processes (added 1 directory level bellow), the CSS and any file within the directory /www/resources/ stopped to work. The visual result is available http://www.evex.co/main/

Inspecting CSS elements (f12 - browser developer tool), I noticed that CSS paths miss the respective extra directory in their paths (i.e. /main/.).

## f12 - browser developer tool ##
...
Failed to load resource: the server responded with a status of 404 (Not Found)
/resources/acs-templating/lists.css Failed to load resource: the server responded with a status of 404 (Not Found)
/resources/acs-templating/forms.css Failed to load resource: the server responded with a status of 404 (Not Found)
2core.js Failed to load resource: the server responded with a status of 404 (Not Found)

...
NGINX serves on port 80 and passes the requests to NaviServer on http://127.0.0.1:8000. Its virtualhost has multiple locations. The one defined to openacs rootdir is /main/.
...
       location /main/ {
              alias /var/www/evex/main;
               proxy_redirect off;
                proxy_http_version 1.1;
                proxy_pass  http://127.0.0.1:8000/;
                proxy_set_header Host www.evex.co;
       }
...

In order to mitigate and avoid errors on the OACS side I set up another config file (i.e. virtualhost) on NGINX, with only one location. http://dev.evex.co/ works just fine, meaning that /ns/conf/openacs-config.tcl is properly set up.

I also explicitly added ALIAS to nginx->location, but paths are still without /main/ in the paths.

How would /main/ be added to CSS (i.e. /main/resources/<package>/...)?

Best wishes,
Iuri

Collapse
2: Re: NGINX and CSS files (response to 1)
Posted by Iuri Sampaio on
I decided to take another approach to the scenario.

I tried to write NGINX settings in the other way around. then, relocated openacs source to / and moved the other source (from another framework) /var/www/oacs/main

But it didn't work either. Only php-fpm succeed. location /oacs/ is wrongly set up.

NGINX settings currently are:
server {
       listen 80;
       server_name dev.evex.co;
       root /var/www/oacs/main;

       location ~ \.php$ {

         proxy_set_header X-Real-IP  $remote_addr;
         proxy_set_header X-Forwarded-For $remote_addr;
         proxy_set_header Host $host;
         proxy_pass http://127.0.0.1:9000;

         }
...
        location /oacs/ {
             alias /var/www/evex;
              proxy_pass http://127.0.0.0.1:8000;
        }
Collapse
3: Re: NGINX and CSS files (response to 1)
Posted by Iuri Sampaio on
Hi there,

It seems I almost got the result. However, CSS and libraries still miss the correct path.

NGINX successfuly returns 200 to ADP and TCL files but it fails with 404 to files within /resources//*

See logs bellow.

Best wishes,

177.148.180.216 - - [02/Jun/2017:23:03:16 -0400] "GET /core/index HTTP/1.1" 200 10182 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/601.7.8 (KHTML, like Gecko) Version/9.1.2 Safari/601.7.7"
177.148.180.216 - - [02/Jun/2017:23:03:16 -0400] "GET /resources/evex-theme/styles/evex-master.css HTTP/1.1" 404 143 "http://dev.evex.co/core/index" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/601.7.8 (KHTML, like Gecko) Version/9.1.2 Safari/601.7.7"
177.148.180.216 - - [02/Jun/2017:23:03:16 -0400] "GET /resources/evex-core/css/base.css HTTP/1.1" 404 143 "http://dev.evex.co/core/index" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/601.7.8 (KHTML, like Gecko) Version/9.1.2 Safari/601.7.7"
177.148.180.216 - - [02/Jun/2017:23:03:16 -0400] "GET /resources/evex-core/css/style.css HTTP/1.1" 404 143 "http://dev.evex.co/core/index" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/601.7.8 (KHTML, like Gecko) Version/9.1.2 Safari/601.7.7"
177.148.180.216 - - [02/Jun/2017:23:03:16 -0400] "GET /resources/acs-templating/lists.css HTTP/1.1" 404 143 "http://dev.evex.co/core/index" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/601.7.8 (KHTML, like Gecko) Version/9.1.2 Safari/601.7.7"
177.148.180.216 - - [02/Jun/2017:23:03:16 -0400] "GET /resources/evex-core/vendor/jquery.min.js HTTP/1.1" 404 143 "http://dev.evex.co/core/index" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/601.7.8 (KHTML, like Gecko) Version/9.1.2 Safari/601.7.7"
177.148.180.216 - - [02/Jun/2017:23:03:16 -0400] "GET /resources/acs-templating/forms.css HTTP/1.1" 404 143 "http://dev.evex.co/core/index" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/601.7.8 (KHTML, like Gecko) Version/9.1.2 Safari/601.7.7"
177.148.180.216 - - [02/Jun/2017:23:03:16 -0400] "GET /resources/evex-core/vendor/webfontloader.js HTTP/1.1" 404 143 "http://dev.evex.co/core/index" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/601.7.8 (KHTML, like Gecko) Version/9.1.2 Safari/601.7.7"
177.148.180.216 - - [02/Jun/2017:23:03:16 -0400] "GET /resources/evex-core/vendor/noframework.waypoints.min.js HTTP/1.1" 404 143 "http://dev.evex.co/core/index" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/601.7.8 (KHTML, like Gecko) Version/9.1.2 Safari/601.7.7"
177.148.180.216 - - [02/Jun/2017:23:03:16 -0400] "GET /resources/evex-core/vendor/swiper.jquery.js HTTP/1.1" 404 143 "http://dev.evex.co/core/index" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/601.7.8 (KHTML, like Gecko) Version/9.1.2 Safari/601.7.7"
177.148.180.216 - - [02/Jun/2017:23:03:16 -0400] "GET /resources/evex-core/js/responsive-nav.js HTTP/1.1" 404 143 "http://dev.evex.co/core/index" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/601.7.8 (KHTML, like Gecko) Version/9.1.2 Safari/601.7.7"
177.148.180.216 - - [02/Jun/2017:23:03:16 -0400] "GET /resources/evex-core/js/popup.js HTTP/1.1" 404 143 "http://dev.evex.co/core/index" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/601.7.8 (KHTML, like Gecko) Version/9.1.2 Safari/601.7.7"
177.148.180.216 - - [02/Jun/2017:23:03:16 -0400] "GET /resources/evex-core/js/bg-videos.js HTTP/1.1" 404 143 "http://dev.evex.co/core/index" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/601.7.8 (KHTML, like Gecko) Version/9.1.2 Safari/601.7.7"
177.148.180.216 - - [02/Jun/2017:23:03:17 -0400] "GET /resources/evex-core/js/fontloader.js HTTP/1.1" 404 143 "http://dev.evex.co/core/index" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/601.7.8 (KHTML, like Gecko) Version/9.1.2 Safari/601.7.7"
177.148.180.216 - - [02/Jun/2017:23:03:17 -0400] "GET /resources/evex-core/js/form-submit.js HTTP/1.1" 404 143 "http://dev.evex.co/core/index" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/601.7.8 (KHTML, like Gecko) Version/9.1.2 Safari/601.7.7"
177.148.180.216 - - [02/Jun/2017:23:03:17 -0400] "GET /resources/acs-subsite/core.js HTTP/1.1" 404 143 "http://dev.evex.co/core/index" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/601.7.8 (KHTML, like Gecko) Version/9.1.2 Safari/601.7.7"
177.148.180.216 - - [02/Jun/2017:23:03:17 -0400] "GET /resources/evex-core/js/background-parallax.js HTTP/1.1" 404 143 "http://dev.evex.co/core/index" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/601.7.8 (KHTML, like Gecko) Version/9.1.2 Safari/601.7.7"
177.148.180.216 - - [02/Jun/2017:23:03:17 -0400] "GET /resources/evex-core/js/page-script.js HTTP/1.1" 404 143 "http://dev.evex.co/core/index" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/601.7.8 (KHTML, like Gecko) Version/9.1.2 Safari/601.7.7"
177.148.180.216 - - [02/Jun/2017:23:03:17 -0400] "GET /resources/evex-core/vendor/jquery.magnific-popup.min.js HTTP/1.1" 404 143 "http://dev.evex.co/core/index" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/601.7.8 (KHTML, like Gecko) Version/9.1.2 Safari/601.7.7"
177.148.180.216 - - [02/Jun/2017:23:03:17 -0400] "GET /resources/evex-core/js/reveal-animation.js HTTP/1.1" 404 143 "http://dev.evex.co/core/index" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/601.7.8 (KHTML, like Gecko) Version/9.1.2 Safari/601.7.7"
177.148.180.216 - - [02/Jun/2017:23:03:17 -0400] "GET /resources/evex-core/images/logo-evex-final.png HTTP/1.1" 404 143 "http://dev.evex.co/core/index" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/601.7.8 (KHTML, like Gecko) Version/9.1.2 Safari/601.7.7"
177.148.180.216 - - [02/Jun/2017:23:03:17 -0400] "GET /resources/evex-core/images/cross.png HTTP/1.1" 404 143 "http://dev.evex.co/core/index" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/601.7.8 (KHTML, like Gecko) Version/9.1.2 Safari/601.7.7"
177.148.180.216 - - [02/Jun/2017:23:03:19 -0400] "GET /core/index HTTP/1.1" 200 10182 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/601.7.8 (KHTML, like Gecko) Version/9.1.2 Safari/601.7.7"
177.148.180.216 - - [02/Jun/2017:23:03:19 -0400] "GET /resources/evex-theme/styles/evex-master.css HTTP/1.1" 404 143 "http://dev.evex.co/core/index" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/601.7.8 (KHTML, like Gecko) Version/9.1.2 Safari/601.7.7"