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

A little confused about trailing slash behavior in nginx

They are totally different. In the first proxy_pass statement you have included a URI parameter with a value of /. In the second you haven’t. When you give proxy_pass a URI parameter (within a prefix location), it transforms the requested URI similarly to the alias function, whereby the value of the location directive is substituted … 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

Nginx serves .php files as downloads, instead of executing them

Try this: Edit /etc/nginx/sites-available/default Uncomment both listen lines to make nginx listen on port 80 IPv4 and IPv6. listen 80; ## listen for ipv4; this line is default and implied listen [::]:80 default_server ipv6only=on; ## listen for ipv6 Leave server_name alone # Make site accessible (…) server_name localhost; Add index.php to the index line root … Read more

Nginx: Redirect non-www to www https

Make one server block a default server and give the other server block the one true server_name. server { listen 80 default_server; listen 443 ssl default_server; ssl_certificate …; ssl_certificate_key …; return 301 https://www.example.com$request_uri; } server { listen 443 ssl; server_name www.example.com; ssl_certificate …; ssl_certificate_key …; … } The default server for https requires a valid … Read more

Why do HTTP servers forbid underscores in HTTP header names

They are not forbidden, it’s CGI legacy. See “Missing (disappearing) HTTP Headers“. If you do not explicitly set underscores_in_headers on;, nginx will silently drop HTTP headers with underscores (which are perfectly valid according to the HTTP standard). This is done in order to prevent ambiguities when mapping headers to CGI variables, as both dashes and … Read more

Increasing client_max_body_size in Nginx conf on AWS Elastic Beanstalk

There are two methods you can take for this. Unfortunately some work for some EB application types and some work for others. Supported/recommended in AWS documentation For some application types, like Java SE, Go, Node.js, and maybe Ruby (it’s not documented for Ruby, but all the other Nginx platforms seem to support this), Elasticbeanstalk has … Read more

Nginx no-www to www and www to no-www

HTTP Solution From the documentation, “the right way is to define a separate server for example.org”: server { listen 80; server_name example.com; return 301 http://www.example.com$request_uri; } server { listen 80; server_name www.example.com; … } HTTPS Solution For those who want a solution including https://… server { listen 80; server_name www.domain.com; # $scheme will get the … Read more