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
55
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
  • 765
  • 3
  • 9
  • 13
54
votes
1 answer

Server Aliases on NGINX

I'm moving a site to a new server running on NGINX. The old site's Apache2 VirtualHost has ServerAlias configured that I want to replicate in the NGINX configuration. From what I've read on the NGINX Docs this seems to be simply achieved with…
Holly
  • 907
  • 5
  • 13
  • 24
54
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,711
  • 3
  • 17
  • 23
54
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
  • 968
  • 1
  • 11
  • 19
54
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,765
  • 2
  • 29
  • 34
53
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
  • 633
  • 1
  • 6
  • 7
51
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,135
  • 2
  • 13
  • 28
51
votes
3 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-
  • 747
  • 1
  • 6
  • 10
51
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
  • 825
  • 2
  • 8
  • 10
51
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
50
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
  • 619
  • 1
  • 7
  • 10
50
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
  • 980
  • 3
  • 10
  • 15
47
votes
3 answers

Why is setting Nginx as a reverse proxy a good idea?

I have a Django site running on Gunicorn with a reverse proxy through Nginx. Isn't Nginx just an extra unnecessary overhead? How does adding that on top of Gunicorn help?
TheOne
  • 595
  • 1
  • 5
  • 6
46
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
  • 723
  • 2
  • 6
  • 11
46
votes
6 answers

Permission denied while reading upstream

We have deployed our rails application on on Nginx and passenger. Intermittently, pages of application get loaded partially. There is no error in application log, but the Nginx error log shows the following: 2011/02/14 05:49:34 [crit] 25389#0: *645…
user68613
  • 583
  • 1
  • 4
  • 6