How to force or redirect to SSL in nginx?

According to nginx pitfalls, it’s slightly better to omit the unnecessary capture, using $request_uri instead. In that case, append a question mark to prevent nginx from doubling any query args. server { listen 80; server_name signup.mysite.com; rewrite ^ https://$server_name$request_uri? permanent; }

Nginx reverse proxy + URL rewrite

Any redirect to localhost doesn’t make sense from a remote system (e.g. client’s Web browser). So the rewrite flags permanent (301) or redirect (302) are not usable in your case. Please try following setup using a transparent rewrite rule: location /foo { rewrite /foo/(.*) /$1 break; proxy_pass http://localhost:3200; proxy_redirect off; proxy_set_header Host $host; } Use … Read more

Why do I need Nginx and something like Gunicorn?

Overly simplified: You need something that executes Python but Python isn’t the best at handling all types of requests. [disclaimer: I’m a Gunicorn developer] Less simplified: Regardless of what app server you use (Gunicorn, mod_wsgi, mod_uwsgi, cherrypy) any sort of non-trivial deployment will have something upstream that will handle the requests that your Django app … Read more

How can I use environment variables in Nginx.conf

From the official Nginx docker file: Using environment variables in nginx configuration: Out-of-the-box, Nginx doesn’t support using environment variables inside most configuration blocks. But envsubst may be used as a workaround if you need to generate your nginx configuration dynamically before nginx starts. Here is an example using docker-compose.yml: image: nginx volumes: – ./mysite.template:/etc/nginx/conf.d/mysite.template ports: … Read more

/blog/wp-json/ nginx return 404

I hope you solved this problem since April 2020. I got some kind of same trouble with the wordpress php files being accessible throw https://example.com/blog/ . When wp had to make some json operations, with js calling urls like https://example.com/blog/wp-json/wp/v2/posts/23?_locale=user for instance, it used to throw a 404 error. I solved this adding an extra … Read more

tech