How to route .html and .js files as PHP on Nginx FastCGI server?

Passing to fastcgi didn’t work for me. After a few hours of searching, I have found solution here: http://ffct.cc/solving-nginx-php-fpm-access-denied-issue/ In short: since PHP versions > 5.3.8, to make it works, you should add directive to your php-fpm.conf: security.limit_extensions = .php .html .js The recognition sign is “Access denied.” (notice that it’s different from HTTP error … Read more

nginx proxy pass Node, SSL?

If you’re using nginx to handle SSL, then your node server will just be using http. upstream nodejs { server 127.0.0.1:4545 max_fails=0; } server { listen 443; ssl on; ssl_certificate newlocalhost.crt; ssl_certificate_key newlocalhost.key; server_name nodejs.newlocalhost.com; add_header Strict-Transport-Security max-age=500; location / { proxy_pass http://nodejs; proxy_redirect off; proxy_set_header Host $host ; proxy_set_header X-Real-IP $remote_addr ; proxy_set_header X-Forwarded-For … Read more

Error 502 in nginx + php5-fpm

The issue is socket itself, its problems on high-load cases is well-known. Please consider using TCP\IP connection instead of unix socket, for that you need to make these changes: in php-fpm pool configuration replace listen = /var/run/php5-fpm.sock with listen = 127.0.0.1:7777 in /etc/nginx/php_location replace fastcgi_pass unix:/var/run/php5-fpm.sock; with fastcgi_pass 127.0.0.1:7777;

django : Serving static files through nginx

I think using root in location block is incorrect. I use alias and it works fine, even without re-configuring django. # django settings.py MEDIA_URL = ‘/static/’ # nginx server config server { … location /static { autoindex on; alias /opt/aa/webroot/; } } Hope this makes things simpler.

nginx docker container: 502 bad gateway response

The Problem Localhost is a bit tricky when it comes to containers. Within a docker container, localhost points to the container itself. This means, with an upstream like this: upstream foo{ server 127.0.0.1:8080; } or upstream foo{ server 0.0.0.0:8080; } you are telling nginx to pass your request to the local host. But in the … Read more

How to serve all existing static files directly with NGINX, but proxy the rest to a backend server.

Use try_files and named location block (‘@apachesite’). This will remove unnecessary regex match and if block. More efficient. location / { root /path/to/root/of/static/files; try_files $uri $uri/ @apachesite; expires max; access_log off; } location @apachesite { proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://127.0.0.1:8080; } Update: The assumption of this config is that … Read more

tech