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
552
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,442
  • 5
  • 23
  • 18
357
votes
29 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,719
  • 2
  • 18
  • 12
308
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
  • 3,245
  • 3
  • 15
  • 7
287
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,975
  • 3
  • 14
  • 6
254
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,489
  • 2
  • 20
  • 16
251
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,663
  • 2
  • 19
  • 10
247
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,725
  • 2
  • 19
  • 10
238
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,725
  • 4
  • 20
  • 15
232
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,910
  • 7
  • 82
  • 106
213
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,245
  • 2
  • 14
  • 4
205
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,211
  • 2
  • 14
  • 10
191
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
  • 3,045
  • 2
  • 18
  • 13
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
165
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
  • 2,205
  • 3
  • 18
  • 19
154
votes
5 answers

How to output variable in nginx log for debugging

I am testing nginx and want to output variables to the log files. How can I do that and which log file will it go (access or error).
lulalala
  • 1,677
  • 2
  • 13
  • 12
1
2 3
99 100