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.

17017 questions
104
votes
10 answers

Properly setting up a "default" nginx server for https

I have several servers running on the same machine, some with http only, some with both http and https. There are several server blocks defined in separate files which are included from the main config file. I have set up a "default" server for…
Roar
102
votes
6 answers

How to force nginx to resolve DNS (of a dynamic hostname) everytime when doing proxy_pass?

I am using nginx/0.7.68, running on CentOS, with the following configuration: server { listen 80; server_name ***; index index.html index.htm index.php default.html default.htm default.php; location / { root …
xiamx
  • 1,212
  • 2
  • 9
  • 10
101
votes
4 answers

"413 Request Entity Too Large" in Nginx with "client_max_body_size" set

I am uploading a 26Gb file, but I am getting: 413 Request Entity Too Large I know, this is related to client_max_body_size, so I have this parameter set to 30000M. location /supercap { root /media/ss/synology_office/server_Seq-Cap/; index…
user2979409
  • 1,111
  • 2
  • 7
  • 4
99
votes
5 answers

How to make a modification take affect without restarting nginx?

Apache has a graceful option which can scan for modification in http.conf without restarting Apache. What about nginx?
vps
  • 1,227
  • 3
  • 13
  • 14
97
votes
5 answers

Disable caching when serving static files with Nginx (for development)

We are using Nginx to serve static files on a development platform. As it is a development platform, we'd like to disable caching so that each change is propagated to the server. The configuration of the VHost is quite simple: server { server_name…
Olivier Chappe
  • 971
  • 1
  • 7
  • 4
96
votes
1 answer

Nested Nginx location (prefix blocks in regex blocks) not working

I'm having trouble understanding nested locations in nginx. I have two locations with some configuration directives in common, so rather than repeat the directives, I'd prefer to repeat the URI using a regular-expression: location ~ /a|/b { …
Jayen
  • 1,857
  • 4
  • 16
  • 28
90
votes
4 answers

Nginx - root versus alias, for serving single files?

After many hours getting nginx to serve single files such as robots.txt (hint: clear your browser cache each time), I wound up with two different ways, one using the alias directive, and one using the root directive, like so: location /robots.txt {…
Cyclops
  • 1,169
  • 2
  • 9
  • 13
89
votes
4 answers

Nginx Redirect via Proxy, Rewrite and Preserve URL

In Nginx we have been trying to redirect a URL as follows: http://example.com/some/path -> http://192.168.1.24 where the user still sees the original URL in their browser. Once the user is redirected, say they click on the link to…
robjohncox
  • 1,045
  • 1
  • 8
  • 7
88
votes
2 answers

Why do I need nginx when I have uWSGI

There are many tutorials on how to configure nginx to cooperate with uWGSI when I want to deploy Django application. But why do I need nginx in this kit? uWSGI itself can serve WSGI Python applications, it can serve static files, it can also do…
user983447
  • 1,127
  • 1
  • 10
  • 10
86
votes
5 answers

What is the difference between Nginx variables $host, $http_host, and $server_name?

What is the difference between the three Nginx variables $host, $http_host, and $server_name? I have a rewrite rule where I'm not sure which one I should be using: location = /vb/showthread.php { #…
Jeff Widman
  • 2,465
  • 4
  • 24
  • 20
82
votes
1 answer

What’s the difference between the “mainline” and “stable” branches of nginx?

There seem to be two active branches of the nginx web server: a “mainline” branch (currently 1.9.x) and a “stable” branch (currently 1.8.x). Can anyone provide an official source that describes the difference between these two branches and how one…
bdesham
  • 1,725
  • 4
  • 14
  • 22
81
votes
9 answers

How to restart Nginx on Mac OS X?

I just installed Nginx on Mac OS X (thanks http://www.kevinworthington.com/nginx-mac-os-snow-leopard-2-minutes/), but how do I restart Nginx on Mac OS X? Thanks!
Laura Brown
  • 843
  • 1
  • 7
  • 5
80
votes
1 answer

Nginx - Meaning of the ~ (tilde) in the location block of the nginx.conf?

What is the meaning of the tilde after the location block in the nginx configuration? for example location ~ ^/download/(.*)$ { alias /home/website/files/$1; } What is the difference between with and without the "~" ?
mahen3d
  • 4,342
  • 14
  • 36
  • 57
80
votes
5 answers

Nginx redirect one path to another

I'm sure this has been asked before, but I can't find a solution that works. A website has switched CMS services, but has the same domain, how do I set up an nginx rewrite for a single page? E.g. Old…
SteveEdson
  • 1,539
  • 3
  • 12
  • 23
79
votes
2 answers

nginx url rewriting: difference between break and last

I don't understand the difference between break and last (flags of rewrite). The documentation is rather abstruse. I've tried to switch between the two in some of my configs, but I couldn't spot any difference in behavior. Can someone please explain…
user39883