Questions tagged [nginx]

Nginx ("eNgine x") is a lightweight, high-performance HTTP server, reverse proxy, TCP stream proxy and mail proxy, released under a BSD-like license.

Nginx is a web server and mail proxy known for its high performance and small resource footprint. It is used in many places as a replacement to Apache and also as a front end server to static content or reverse proxying. Nginx is developed under a BSD-like license by Kazakhstani developer Igor Sysoev.

Nginx comes with diverse modules that enable it to perform various different tasks such as load balancing, URL rewriting, request rate limiting, content compression, raw TCP proxying and integration with tools like memcached or scripting languages like Lua.

Nginx is being used by some of the worlds busiest sites like WordPress, Sourceforge, Github and Reddit. Its market share has been raising from 7% in 2008 to over 30% as of June 2016 according to W3techs statistics.

After nine years of development, Nginx 1.0 stable was released on April 2011.

16419 questions
548
votes
11 answers

In Nginx, how can I rewrite all http requests to https while maintaining sub-domain?

I want to rewrite all http requests on my web server to be https requests, I started with the following: server { listen 80; location / { rewrite ^(.*) https://mysite.com$1 permanent; } ... One Problem is that this…
MikeN
  • 8,252
  • 5
  • 22
  • 18
336
votes
23 answers

How can I use environment variables in Nginx.conf

I have a docker container running Nginx, that links to another docker container. The host name and IP address of the second container is loaded into the Nginx container as environment variables on startup, but is not know before then (it's dynamic).…
Hugo Rodger-Brown
  • 3,507
  • 2
  • 17
  • 12
282
votes
5 answers

Nginx reverse proxy + URL rewrite

Nginx is running on port 80, and I'm using it to reverse proxy URLs with path /foo to port 3200 this way: location /foo { proxy_pass http://localhost:3200; proxy_redirect off; proxy_set_header …
jeffreyveon
  • 2,985
  • 3
  • 14
  • 7
281
votes
4 answers

Why do I need Nginx and something like Gunicorn?

I'm looking for an overly simplified answer to the following question. I'm trying to build a foundational understanding of how Nginx works alongside something like Gunicorn. Do I need both Nginx and something like Gunicorn to deploy Django apps on…
a.m.
  • 2,915
  • 3
  • 13
  • 6
248
votes
4 answers

How can I see which flags Nginx was compiled with?

How can I check what modules have been added to an nginx installation?
Nisanio
  • 2,633
  • 2
  • 18
  • 10
236
votes
7 answers

How to force or redirect to SSL in nginx?

I have a signup page on a subdomain like: https://signup.example.com It should only be accessible via HTTPS but I'm worried people might somehow stumble upon it via HTTP and get a 404. My html/server block in nginx looks like this: html { server…
Callmeed
  • 2,705
  • 4
  • 18
  • 15
229
votes
8 answers

How do I add Access-Control-Allow-Origin in NGINX?

How do I set the Access-Control-Allow-Origin header so I can use web-fonts from my subdomain on my main domain? Notes: You'll find examples of this and other headers for most HTTP servers in the HTML5BP Server Configs projects…
Chris McKee
  • 3,119
  • 2
  • 19
  • 16
226
votes
6 answers

How to reply with 200 from Nginx, without serving a file?

I have configured Apache to send back a 200 response without serving any file with this configuration line Redirect 200 /hello Can I do this with Nginx? I don't want to serve a file, I just want the server to respond with a 200 (I'm just logging…
Theo
  • 2,505
  • 2
  • 18
  • 10
226
votes
5 answers

nginx HTTPS serving with same config as HTTP

Is there a way to share configuration directives across two nginx server {} blocks? I'd like to avoid duplicating the rules, as my site's HTTPS and HTTP content are served with the exact same config. Currently, it's like this: server { listen 80; …
ceejayoz
  • 32,469
  • 7
  • 81
  • 105
189
votes
6 answers

Nginx config reload without downtime

I use nginx as a reverse proxy. Whenever I update the config for it using sudo "cp -r #{nginx_config_path}* /etc/nginx/sites-enabled/" sudo "kill -s HUP `cat /var/run/nginx.pid`" I face a brief downtime. How can I avoid that?
Saurav Shah
  • 2,005
  • 2
  • 13
  • 4
187
votes
5 answers

Difference in sites-available vs sites-enabled vs conf.d directories (Nginx)?

I have some experience using linux but none using nginx. I have been tasked with researching load-balancing options for an application server. I have used apt-get to install nginx and all seems fine. I have a couple of questions. What is the…
Seth Spearman
  • 2,031
  • 2
  • 13
  • 10
183
votes
18 answers

How do you restart php-fpm?

I need to reload my php.ini and there's nothing in the help dialog about restarting it.
Galen
  • 1,983
  • 2
  • 12
  • 10
180
votes
10 answers

Nginx enable site command

We all know how to enable a website using apache on Linux. I'm pretty sure that we all agree on using the a2ensite command. Unfortunately, there is no default equivalent command that comes with Nginx, but it did happen that I installed some package…
HXH
  • 2,905
  • 2
  • 17
  • 13
151
votes
13 answers

How to set up Nginx as a caching reverse proxy?

I heard recently that Nginx has added caching to its reverse proxy feature. I looked around but couldn't find much info about it. I want to set up Nginx as a caching reverse proxy in front of Apache/Django: to have Nginx proxy requests for some (but…
Continuation
  • 3,050
  • 5
  • 29
  • 38
146
votes
5 answers

How to remove the path with an nginx proxy_pass

I have a running web-application at http://example.com/, and want to "mount" another application, on a separate server on http://example.com/en. Upstream servers and proxy_pass seem to work, but for one issue: upstream luscious { server…
berkes
  • 1,975
  • 3
  • 15
  • 18
1
2 3
99 100