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.

Filter by
Sorted by
Tagged with
554 votes
11 answers
593k views

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 ...
MikeN's user avatar
  • 8,482
361 votes
29 answers
491k views

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 ...
Hugo Rodger-Brown's user avatar
309 votes
5 answers
700k views

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; ...
jeffreyveon's user avatar
  • 3,255
290 votes
4 answers
118k views

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 ...
a.m.'s user avatar
  • 3,005
256 votes
8 answers
980k views

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 ...
Chris McKee's user avatar
  • 3,499
254 votes
6 answers
292k views

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 ...
Theo's user avatar
  • 2,795
251 votes
4 answers
168k views

How can I see which flags Nginx was compiled with?

How can I check what modules have been added to an nginx installation?
Nisanio's user avatar
  • 2,673
238 votes
7 answers
340k views

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/...
Callmeed's user avatar
  • 2,725
233 votes
5 answers
248k views

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. ...
ceejayoz's user avatar
  • 33.1k
217 votes
6 answers
432k views

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 ...
Saurav Shah's user avatar
  • 2,285
208 votes
5 answers
202k views

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 ...
Seth Spearman's user avatar
193 votes
10 answers
494k views

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, ...
HXH's user avatar
  • 3,065
183 votes
18 answers
1.1m views

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's user avatar
  • 1,983
165 votes
5 answers
309k views

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 ...
berkes's user avatar
  • 2,205
154 votes
5 answers
262k views

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's user avatar
  • 1,677
152 votes
13 answers
182k views

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/...
Continuation's user avatar
  • 3,110
151 votes
7 answers
394k views

Make nginx to pass hostname of the upstream when reverseproxying

I run several docker containers with hostnames: web1.local web2.local web3.local Routing to these done based on hostname by nginx. I have a proxy in front of this setup (on different machine ...
pavel_karoukin's user avatar
150 votes
2 answers
292k views

Is it possible to make Nginx listen to different ports?

I created one Nginx with one Linux Azure VM, is it possible to make nginx listen to different ports so that when I change the port number, the content would be different. I found there would be a ...
billcyz's user avatar
  • 1,770
142 votes
8 answers
713k views

connect() failed (111: Connection refused) while connecting to upstream

I'm experiencing 502 Gateway errors when accessing a PHP file in a directory (http://example.com/dev/index.php). The logs simply says this: 2011/09/30 23:47:54 [error] 31160#0: *35 connect() failed (...
MacMac's user avatar
  • 2,091
136 votes
12 answers
204k views

Can I hide all server / os info?

I don't want anyone to be able to detect that I'm using NGINX or even Ubuntu from the internet. There are tools out there (such as BuiltWith) which scan servers to detect what tools they're using. ...
orokusaki's user avatar
  • 2,803
127 votes
4 answers
366k views

Nginx: How do I forward an HTTP request to another port?

What I want to do is: When someone visits http://localhost/route/abc the server responds exactly the same as http://localhost:9000/abc Now I configure my Nginx server like this: location /route { ...
WoooHaaaa's user avatar
  • 1,625
124 votes
16 answers
469k views

Nginx 1 FastCGI sent in stderr: “Primary script unknown”

My first time using Nginx, but I am more than familiar with Apache and Linux. I am using an existing project and when ever I am trying to see the index.php I get a 404 File not found. Here is the ...
We0's user avatar
  • 1,439
118 votes
4 answers
296k views

How to disable timeout for nginx?

On a local development machine, I have a nginx reverse proxy like so: server { listen 80; server_name myvirtualhost1.local; location / { proxy_pass http://127.0.0.1:8080; } server { ...
k0pernikus's user avatar
  • 4,270
118 votes
2 answers
278k views

How does try_files work?

I looked at the nginx documentation and it still confuses me utterly. How does try_files work? Here is what the documentation says: From NginxHttpCoreModule try_files syntax: try_files path1 ...
user avatar
114 votes
3 answers
230k views

nginx - client request body is buffered to a temporary file

I get the following error in my log files every time I try to upload a large file. a client request body is buffered to a temporary file /var/lib/nginx/body/0000000001 Although the file uploads ...
Abs's user avatar
  • 1,579
113 votes
8 answers
218k views

What does this nginx error "rewrite or internal redirection cycle" mean?

tail -f /var/log/nginx/error.log 2013/05/04 23:43:35 [error] 733#0: *3662 rewrite or internal redirection cycle while internally redirecting to "/index.html", client: 127.0.0.1, server: _, request: "...
pavs-maha's user avatar
  • 1,133
112 votes
7 answers
386k views

How to restart nginx?

For me, I run "killall nginx" and start it by "sbin/nginx", anyone has a better restart script? BTW: I install nginx from source, i do not find 'service nginx' command or /etc/init.d/nginx
larry's user avatar
  • 4,067
112 votes
8 answers
194k views

Setting the "Expires" HTTP header for static content served from Nginx?

I'm using nginx to server my static content, is there a way that I can set the expires headers for every file that meets a specific rule? For example can I set the expires header for all files that ...
Unkwntech's user avatar
  • 1,759
112 votes
5 answers
106k views

Do you need separate IPv4 and IPv6 listen directives in nginx?

I've seen various config examples for handling dual-stack IPv4 and IPv6 virtual hosts on nginx. Many suggest this pattern: listen 80; listen [::]:80 ipv6only=on; As far as I can see, this achieves ...
Synchro's user avatar
  • 3,190
108 votes
3 answers
209k views

an upstream response is buffered to a temporary file

I have a rather large and slow (complex data, complex frontend) web application build in RoR and served by Puma with nginx as reverse proxy. Looking at the nginx error log, I see quite a few entries ...
ngw's user avatar
  • 1,281
105 votes
10 answers
107k views

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 ...
user avatar
104 votes
6 answers
200k views

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 ...
xiamx's user avatar
  • 1,232
101 votes
4 answers
159k views

"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 /...
user2979409's user avatar
  • 1,111
99 votes
5 answers
97k views

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's user avatar
  • 1,227
97 votes
1 answer
134k views

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 ...
Jayen's user avatar
  • 1,867
97 votes
5 answers
111k views

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 ...
Olivier Chappe's user avatar
91 votes
4 answers
105k views

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 ...
Cyclops's user avatar
  • 1,179
89 votes
4 answers
333k views

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 ...
robjohncox's user avatar
  • 1,045
89 votes
5 answers
105k views

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's user avatar
  • 2,515
88 votes
2 answers
35k views

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 ...
user983447's user avatar
  • 1,127
84 votes
1 answer
47k views

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 ...
bdesham's user avatar
  • 1,755
82 votes
1 answer
65k views

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 ...
mahen3d's user avatar
  • 4,382
81 votes
9 answers
262k views

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's user avatar
80 votes
5 answers
350k views

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. ...
SteveEdson's user avatar
  • 1,539
80 votes
2 answers
89k views

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 ...
user avatar
80 votes
11 answers
68k views

Remove "www" and redirect to "https" with nginx

I want to create a rule in nginx that does two things: Removes the "www." from the request URI Redirects to "https" if the request URI is "http" There are plenty of examples of how to do each of ...
Devin's user avatar
  • 923
80 votes
4 answers
120k views

nginx real_ip_header and X-Forwarded-For seems wrong

The wikipedia description of the HTTP header X-Forwarded-For is: X-Forwarded-For: client1, proxy1, proxy2, ... The nginx documentation for the directive real_ip_header reads, in part: This ...
Kirk Woll's user avatar
  • 903
77 votes
11 answers
139k views

How can I create a location in nginx that works with AND without a trailing slash?

Right now I have this config: location ~ ^/phpmyadmin/(.*)$ { alias /home/phpmyadmin/$1; } However, if I visit www.mysite.com/phpmyadmin (note the lack of trailing slash), it won't find what ...
Rob's user avatar
  • 2,413
77 votes
5 answers
82k views

Dump nginx config from running process?

Apparently, I shouldn't have spent sleepless night trying to debug an application. I wanted to restart my nginx and discovered that its config file is empty. I don't remember truncating it, but fat ...
Sergio Tulentsev's user avatar
72 votes
3 answers
186k views

nginx: Log complete request / response with all headers?

We have an application server that sometimes hangs. We suspect it is due to a bad request from a client. Can nginx log the complete request/response (like fiddler captures) to files, so we can see ...
Jonesome Reinstate Monica's user avatar

1
2 3 4 5
343