Assigning vhosts to Docker ports

This answer might be a bit late, but what you need is an automatic reverse proxy. I have used two solutions for that: jwilder/nginx-proxy Traefik With time, my preference is to use Traefik. Mostly because it is well documented and maintained, and comes with more features (load balancing with different strategies and priorities, healthchecks, circuit … Read more

NGINX + uWSGI Connection Reset by Peer

make sure to consume your post data in your application for example if you have a Django/python application def my_view(request): # ensure to read the post data, even if you don’t need it # without this you get a: failed (104: Connection reset by peer) data = request.DATA return HttpResponse(“Hello World”) Some details: https://uwsgi-docs.readthedocs.io/en/latest/ThingsToKnow.html

SSL Pass-Through in Nginx Reverse proxy?

Not sure how much it can work in your situation, but newer (1.9.3+) versions of Nginx can pass (encrypted) TLS packets directly to an upstream server, using the stream block : stream { server { listen 443; proxy_pass backend.example.com:443; } } If you want to target multiple upstream servers, distinguished by their hostnames, this is … Read more

nginx redirect HTTPS to HTTP

The answer above will work, you need to generate a self signed cert (or have a real one) and configure nginx as such: server { listen *:443; ssl on; server_name domain.com; rewrite ^(.*) http://domain.com$1 permanent; ssl_certificate /data/certs/domain.crt; ssl_certificate_key /data/certs/domain.key; } Keep in mind, if it is a self signed cert the browser will give you … Read more

NGINX try_files + alias directives

We could not get it to work by specifying root within the location block. The solution for us was to use alias instead. Note that it is necessary repeat the location’s path twice in the try_files directive, and then also in the .php configuration block: server { server_name localhost; root /app/frontend/www; location /backend/ { alias … Read more

nginx add headers when returning 400 codes

For nginx >= 1.7.5 Append “always” to the header definition: add_header ‘Access-Control-Allow-Origin’ ‘*’ always; For nginx < 1.7.5 According to the nginx official document of ngx_header_module, the add_header can’t work when response code is 400 syntax: add_header name value; default: — context: http, server, location, if in location Adds the specified field to a response … Read more