Adding and using header (HTTP) in nginx [closed]

To add a header, add the add_header declaration to either the location block or the server block: server { add_header X-server-header “my server header content!”; location /specific-location { add_header X-location-header “my specific-location header content!”; } } An add_header declaration within a location block will override the same add_header declaration in the outer server block. e.g. … Read more

Disable nginx cache for JavaScript files

I have the following nginx virtual host (static content) for local development work to disable all browser caching: server { listen 8080; server_name localhost; location / { root /your/site/public; index index.html; # kill cache add_header Last-Modified $date_gmt; add_header Cache-Control ‘no-store, no-cache’; if_modified_since off; expires off; etag off; } } No cache headers sent: $ curl … Read more

A better way to restart/reload Gunicorn (via Upstart) after ‘git pull’ing my Django projects

You can tell Gunicorn to reload gracefully using the HUP signal like so: kill -HUP <pid> (see the FAQ for details) I use Supervisor to control my Gunicorn server, which allows me to use this (slightly hacky) way of reloading Gunicorn after a deploy: supervisorctl status gunicorn | sed “s/.*[pid ]\([0-9]\+\)\,.*/\1/” | xargs kill -HUP … Read more

jQuery Upload Progress and AJAX file upload

Uploading files is actually possible with AJAX these days. Yes, AJAX, not some crappy AJAX wannabes like swf or java. This example might help you out: https://webblocks.nl/tests/ajax/file-drag-drop.html (It also includes the drag/drop interface but that’s easily ignored.) Basically what it comes down to is this: <input id=”files” type=”file” /> <script> document.getElementById(‘files’).addEventListener(‘change’, function(e) { var file … Read more

Why does Nginx return a 403 even though all permissions are set properly?

I experienced the same problem and it was due to SELinux. To check if SELinux is running: # getenforce To disable SELinux until next reboot: # setenforce Permissive Restart Nginx and see if the problem persists. If you would like to permanently alter the settings you can edit /etc/sysconfig/selinux If SELinux is your problem you … Read more

Are a WSGI server and HTTP server required to serve a Flask app?

When you “run Flask” you are actually running Werkzeug’s development WSGI server, and passing your Flask app as the WSGI callable. The development server is not intended for use in production. It is not designed to be particularly efficient, stable, or secure. It does not support all the possible features of a HTTP server. Replace … Read more

HTTP2 with node.js behind nginx proxy

In general, the biggest immediate benefit of HTTP/2 is the speed increase offered by multiplexing for the browser connections which are often hampered by high latency (i.e. slow round trip speed). These also reduce the need (and expense) of multiple connections which is a work around to try to achieve similar performance benefits in HTTP/1.1. … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)