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

WordPress sub-directory on other server running on nginx?

Just for sharing my experience to others: I have main site with domian.com and want to subdirectory domain.com/blog reverse proxy to blog.domain.com which is a wordpress with nginx! so this is how things work for me: HTTP version: 1- in domian.com nginx config set /blog like this: listen 80; server_name domain.com www.domain.com; location / { … Read more

NGINX+wordpress: CSS being served but not applied

My nginx config did not include the mime.types defaults. That seems to be affecting the nginx “Content-Type” response header, leading to it being “text/plain” instead of “text/css” … … which is unfortunate because none of the wordpress templates specify the content type in the request, e.g: <link rel=”stylesheet” id=’wp-block-library-css’ href=”https://censored.net/wp-includes/css/dist/block-library/style.css?ver=5.8″ media=”all” /> Should probably look … Read more

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