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
59
votes
2 answers

How can I configure nginx locations to share common configuration options?

How can i configure a shared config block for a set of locations? location / { proxy_pass http://127.0.0.1:9000/; proxy_redirect off; proxy_set_header Host $http_host; …
netbrain
  • 753
  • 1
  • 6
  • 11
58
votes
4 answers

What is the best nginx compression gzip level?

I'm using nginx reverse proxy cache with gzip enabled. However, I got some problems from Android applications HTTP-requests to my Rails JSON web service. It seems when I turn off reverse proxy cache, it works ok because the response header comes…
Chamnap
  • 795
  • 3
  • 9
  • 13
57
votes
2 answers

Lets Encrypt with an nginx reverse proxy

Introduction I have a dev server (currently running Ubuntu 14.04 LTS), which I have been using for a while now for hosting various development tools on different ports. Because the ports can be hard to remember I have decided to to use port 80 for…
0x450
  • 673
  • 1
  • 6
  • 7
57
votes
4 answers

nginx proxy pass redirects ignore port

So I'm setting up a virtual path when pointing at a node.js app in my nginx conf. the relevant section looks like so: location /app { rewrite /app/(.*) /$1 break; proxy_pass http://localhost:3000; proxy_redirect off; proxy_set_header Host…
Paul
  • 998
  • 1
  • 11
  • 19
56
votes
3 answers

Configure Nginx as reverse proxy with upstream SSL

I try to configure an Nginx server as a reverse proxy so the https requests it receives from clients are forwarded to the upstream server via https as well. Here's the configuration that I use: http { # enable reverse proxy proxy_redirect …
Alex Flo
  • 1,761
  • 3
  • 18
  • 23
55
votes
4 answers

nginx without server_name and using only static ip address?

this is my first web app deployment and am running into all sorts of issues. I am currently going for a nginx + gunicorn implementation for the Django app, but mostly this question relates to nginx configurations. For some context - nginx would…
bash-
  • 797
  • 2
  • 6
  • 10
55
votes
5 answers

Ordering: 1. nginx 2. varnish 3. haproxy 4. webserver?

I've seen people recommend combining all of these in a flow, but they seem to have lots of overlapping features so I'd like to dig in to why you might want to pass through 3 different programs before hitting your actual web server. nginx: ssl:…
Joel K
  • 5,853
  • 2
  • 30
  • 34
54
votes
4 answers

How to enable correct charset HTTP-header in NGINX

What is the right way to enable correct charset headers in NGINX? I'm analyzing my website with Google Page Speed. It says that I should specify the charset of HTML files in HTTP-headers. What is the right way to do this? I already tried to set…
pvorb
  • 1,050
  • 3
  • 11
  • 16
54
votes
3 answers

Proxy HTTPS requests to a HTTP backend with NGINX

I have nginx configured to be my externally visible webserver which talks to a backend over HTTP. The scenario I want to achieve is: Client makes HTTP request to nginx which is redirect to the same URL but over HTTPS nginx proxies request over…
Mike
  • 875
  • 2
  • 8
  • 10
53
votes
1 answer

nginx: no permission to bind port 8090 but it binds to 80 and 8080

I'm struggling with some strange permission related behavior: when I configure nginx to listen to port 8080 everything works as expected, but when I use any other port I get something like 2014/01/10 09:20:02 [emerg] 30181#0: bind() to 0.0.0.0:8090…
frans
  • 649
  • 1
  • 7
  • 10
53
votes
4 answers

how to restrict access to directory and subdirs

I need to restrict access to any files or subdirs in direstory "testdir". My conf: ... location ~* ^.+\.(jpg|txt)$ { root /var/www/site; } location /testdir { deny all; return 404; } ... In my…
tst
52
votes
1 answer

nginx server directive is not allowed here

I know there are dupes of this out there, but I can't seem to solve this in my situation. I'm following an article on setting up nginx as reverse proxy with apache. And I get this error: nginx: [emerg] "server" directive is not allowed here in …
gideon
  • 1,145
  • 2
  • 13
  • 28
50
votes
1 answer

How to resolve the gunicorn critical worker timeout error?

I have used nginx and gunicorn to host my website in two servers, Both server have same versions of packages and website is successfully hosted, But in one of my server gunicorn always gets timeout and I get error [CRITICAL]Worker Timeout Booting…
s.m
  • 603
  • 1
  • 5
  • 8
48
votes
2 answers

nginx split large configuration file

My nginx default configuration file is becoming huge. I'd like to split it to smaller config files, each including only one, maximum 4 locations to each file, so that I can enable/disable them quickly. Actual file looks like this: server { …
oliverjkb
  • 614
  • 1
  • 6
  • 10
48
votes
5 answers

How to disable Nginx logging?

I have the following in config file server { listen 80; server_name _; access_log /var/log/nginx/access.log main; ... server { listen 80; server_name example.com access_log off; error_log off; But it…
user965363
  • 743
  • 2
  • 6
  • 11