Nginx ("engine x") is a lightweight, high-performance HTTP server, reverse proxy, TCP stream proxy and mail proxy, released under a BSD-like license.

learn more… | top users | synonyms

6
votes
3answers
4k views

How to proxy /grafana with nginx?

I've setup and started default grafana and it works as expected on http://localhost:3000. I'm trying to proxy it with nginx where I have ssl installed. I'm trying to have it respond to ...
5
votes
2answers
10k views

Nginx Rewrite Convert Querystring to Path

I whould like this simple rewrite rule: /somefolder/mypage.aspx?myid=4343&tab=overview to be redirected to: /folder/4343/overview/ I looked for some solutions and none actually worked.. I ...
5
votes
2answers
3k views

Cheap way to detect client round trip times for http

I am trying to figure out a way to detect round trip times for each IP that connects to port 80 on my server. What is a good way to do this? There are far to many connections, and pinging each ip is ...
5
votes
1answer
9k views

How can I observe what nginx is doing? (to solve: “1024 worker_connections are not enough”)

I have a very low traffic site running on nginx, with 4 workers, 1024 connections each. Every several hours I start seeing in the error log "1024 worker_connections are not enough", and my site slows ...
4
votes
4answers
5k views

Dynamic nginx domain root path based on hostname?

I am trying to setup my development nginx/PHP server with a basic master/catch-all vhost config so that I can created unlimited ___.framework.loc domains as needed. server { listen 80; ...
4
votes
2answers
5k views

Server has apache installed. How to install nginx alongside it?

APache is installed and is used to serve mostly Djanfo/Python content. I want to install nginx to serve static content. How to do it and what is agood configuration. I am on ubuntu and Apache was ...
3
votes
1answer
3k views

uwsgi_params not in nginx

Firstly I setup nginx and uwsgi via apt-get. And,I add the line to nginx conf file(/etc/nginx/conf.d/default.conf) like below line; server { listen 80; server_name <replace with your ...
3
votes
3answers
7k views

Is it possible to log the response data in nginx access log?

I am trying to print the response data for development/debugging purposes. I couldn't find a similar question or any info on this. If you do, please add a comment.
2
votes
1answer
11k views

How To use fail2ban for Nginx? [closed]

How can I use fail2ban on an Nginx server? What are the rules to put in the jails.conf?
10
votes
2answers
1k views

Prefer IPv4 incoming connections over IPv6

We run a social/local service that benefits from geolocating the IP of users. The problem is that with IPv6, geolocation is quite a bit spottier than with IPv4. Is there a way to prefer incoming ...
9
votes
1answer
3k views

NGINX convert HEAD to GET requests

Due to some terrible design decisions, we have an application unable to respond to HTTP HEAD requests (Returns 'Method Not Allowed'). Modifying the software to return HEAD requests correctly would be ...
8
votes
5answers
4k views

Nginx + Apache trailing slash redirect [closed]

I have a Nginx server running on 80 port working as a proxy to Apache 2.2 which is listening to 127.0.0.1:8080 When I access http://hostname/subfolder/ it works great. When I access ...
6
votes
1answer
3k views

How to define which SSL certificate nginx sends first with SNI?

I use nginx 1.2.7 with OpenSSL 0.9.8o on Debian Squeeze for about 30 domains. On two of them I enabled SSL which works fine on both. The SSL config is use for both domains: listen 443 ssl; ...
6
votes
3answers
8k views

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 ...
6
votes
3answers
7k views

Nginx - Route all requests to single script

I have a PHP script that handles script routing and does all sorts of fancy things. It was originally designed for Apache, but I'm trying to migrate it to nginx for a few of my boxes. Right now, I'm ...
6
votes
6answers
4k views

PHP-CGI Started Serving Blank Pages

My PHP-CGI started serving blank pages for no apparent reason until I restarted the process. I want to know why. Unfortunately the "production" configuration file of PHP has no error_log by default. ...
5
votes
2answers
7k views

Prevent nginx from redirecting traffic from https to http when used as a reverse proxy

Here's my abbreviated nginx vhost conf: upstream gunicorn { server 127.0.0.1:8080 fail_timeout=0; } server { listen 80; listen 443 ssl; server_name domain.com ~^.+\.domain\.com$; ...
5
votes
2answers
7k views

“ImportError: No module named flask” - Trouble with nginx + uWSGI + Flask in a virtualenv setup

I got nginx + uWSGI running on localhost inside a virtualenv with a simple hello world program, but I get this error when I replace the hello world with a simple Flask app: File ...
5
votes
1answer
6k views

Nginx + PHP-FPM = “Random” 502 Bad Gateway

I am running Nginx and proxying php requests via FastCGI to PHP-FPM for processing. I will randomly receive 502 Bad Gateway error pages - I can reproduce this issue by clicking around my PHP websites ...
4
votes
3answers
7k views

Howto Nginx + git-http-backend + fcgiwrap (Debian Squeeze)

I am trying to setup git-http-backend with Nginx but after 24 hours wasting time and reading everything I could I think this config should work but doesn't. server { listen 80; server_name ...
4
votes
3answers
8k views

Can Nginx handle php (or similar fcgi) requests inside of an alias?

I am converting a legacy Apache server to Nginx and do not have the luxury of changing URL's or rearranging the filesystem. Is it possible to use nested location{} blocks in the Nginx configuration ...
2
votes
2answers
1k views

Building an SSL server farm

I'm interested in building the the architecture in the article referenced below. I currently have a modestly-priced layer-4 load balancer and my application servers are the SSL endpoints. I want to ...
2
votes
2answers
4k views

Nginx load balance with dedicated php-fpm server

I got server setup with nginx+php-fpm and mysql. I have another server with only installed php-fpm, so wanted to use as load balance. But when I am using this dedicated server with php-fpm as load ...
2
votes
4answers
5k views

nginx logrotate config

Whats the best way to rotate nginx logfiles? In my opinion, I should create a file "nginx" in /etc/logrotate.d/ and fill it with the following code and do a /etc/init.d/syslog restart after that. ...
2
votes
3answers
2k views

NginX & PHP-FPM, random 502

2010/09/19 14:52:07 [error] 1419#0: *10220 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: [...], server: [...], request: "POST /[...] HTTP/1.1", ...
1
vote
1answer
611 views

nginx - limiting bandwidth usage per server block

In Apache we have some great solutions for limiting the bandwidth usage per vhost, like mod_bandwidth. However, since I started using nginx, I couldn't find a way of limiting and monitoring the ...
1
vote
1answer
1k views

Best way to set up permissions with nginx + php-fpm on shared hosting?

I'm running a shared hosting server with nginx and php-fpm on Debian. Everything works fine, php-fpm has separate pools for each users running as separate users and they each have their own socks. ...
0
votes
2answers
9k views

How to optimize Time To First Byte (TTFB)?

I have nginx+apache web-server with several sites. But with very long Time To First Byte (TTFB): 0,5-2 seconds for every request (for static & dynamic content). How to optimize Time To First ...
12
votes
3answers
1k views

The downsides of using nginx as a primary web server?

I've seen millions of websites using nginx as a proxifying webserver working together with Apache. But I've seen very few servers running nginx only as their default webserver. What are the main ...
11
votes
3answers
2k views

nginx: How to prevent an exactly named SSL server block from acting as the catchall for all SSL

I have a web server with many virtual servers. Only 1 of which is SSL. The problem is, because there is no catchall server block listening for SSL, any https request to the other sites is served by ...
10
votes
2answers
4k views

Nginx add_header for a 50* page

I'm currently trying to get nginx to add a header to the response when it is sending some kind of 50* error. I already have an add_header directive on the http block, and that gets respected for all ...
10
votes
3answers
19k views

Understanding this error: apr_socket_recv: Connection reset by peer (104)

So, if I do some benchmarking with apache benchmark (ab), and I use large numbers of requests. Then sometimes in the middle of a test I get this error. I don't even know what it means. So how can I ...
9
votes
1answer
12k views

How do I set a default host for nginx?

I'm trying to figure out how to set a default host for my nginx installation. I found this article in the nginx Wiki: http://wiki.nginx.org/NginxVirtualHostExample#A_Default_Catchall_Virtual_Host ...
7
votes
1answer
8k views

How to upgrade nginx from 1.2 to 1.6 on debian 7

I've looked through the whole web but couldn't find anything ! I modified sources.list but the server is tuck to nginx 1.2 , I don't know what to do please help
7
votes
1answer
16k views

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

I keep seeing the below error message's in the error log, I can access all of the resources but I'm unsure as to why the error is flagging. error: [error] 13368#0: *449 connect() failed (111: ...
7
votes
1answer
17k views

How to configure php-fpm to log logs to log files configured in nginx virtualhosts

I have Fedora 16 with nginx and php-fpm. Everything is working very good. All logs with php notice,warnig error etc. are in /var/log/php-fpm/www-error.log. Is there a way to configure php-fpm to write ...
6
votes
2answers
13k views

nginx reverse proxy - try upstream A, then B, then A again

I'm trying to set up nginx as a reverse proxy, with a large number of backend servers. I'd like to start up the backends on-demand (on the first request that comes in), so I have a control process ...
6
votes
1answer
4k views

My nginx rewrite is downloading the php file

I have the following rewrite rule I'm trying: location / { index index.php index.html; rewrite ^/test$ /test.php break; } And I ...
6
votes
2answers
12k views

Nginx $document_root$fastcgi_script_name vs $request_filename

I can't notice any difference if in my config file I set fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; Or: fastcgi_param SCRIPT_FILENAME $request_filename; What do ...
6
votes
1answer
4k views

Working Nginx fastcgi_cache php-fpm cache and static file caching configuration?

Nginx wiki is very vague with explanation as to how to properly setup nginx with php-fpm with fastcgi_caching for sites which have cookies i.e. wordpress, drupal, vbulletin etc. I downloaded a ...
6
votes
3answers
5k views

Mapping hudson to a subdomain through nginx proxying

I'm now trying to setup nginx as a reverse proxy for Hudson so it can be access on http://build.example.com directly. I've already installed Hudson on Tomcat and verified that I can access Hudson on ...
6
votes
4answers
6k views

Nginx + PHP 5.3.3 (with php-fpm) - memory usage?

I recently bought Xen VPS (linode.com) with Debian 5.0 Lenny (i386), 512MB RAM. At the moment I have only three small websites (built with Drupal) with about 600 users per day in total running on this ...
5
votes
2answers
1k views

NGINX Serving Large mp4 Files extremely inefficiently

I am currently running nginx/1.0.15 on a Centos 6.6 OS. The server has the following specs: Intel(R) Atom(TM) CPU C2750 @ 2.40GHz (8 cores) 32GB Ram 5 x 6000 GB 7200 RPM (Raid 10) The Problem The ...
5
votes
2answers
14k views

Nginx Setting server_names_hash_max_size and server_names_hash_bucket_size

We are using Nginx as a reverse proxy to Apache in a service that gives anyone their own website. At account creation, the system creates a new nginx conf file for the domain with two entries, one for ...
5
votes
1answer
5k views

How to extract Only the file name from the request uri

I am trying to rewrite the request uri depending on the extension of the file, then extract only the file name from the uri and store it in another folder. The problem here is no predefined variable ...
5
votes
1answer
4k views

Mixed IP and Name Based Virtual Hosts with nginx

I set up many domains but I dont know how to configure if only ip address is given. say foo.com I have a setup to go web/foo.com/htdocs, I want to 88.99.66.55 ip address like a domain to ...
4
votes
2answers
1k views

How to check multiple CRL lists with nginx client authentication?

I have a custom easyrsa setup with a root and three CAs signed by the root. (Three different sub-cas depending on the user type), like this: RootCA +----- AdminUserCA +----- EmployeeCA +----- ...
4
votes
1answer
6k views

Nginx set a variable conditionally

I want to allow 1GB uploads on a specific subdomain of my site called upload.xxx.xx.xx. Currently I am trying something like: server { if ( $host = 'upload.xxx.xx.xx' ) { ...
4
votes
2answers
6k views

Setting up a reverse proxy to cache images

I wrote a quick Python server to serve resampled images. For example, a URL might look something like http://images.domain.com/resample/100x100/9f362e1994264321.jpg. Being that resampling images is ...
4
votes
1answer
8k views

How to use nginx as reverse proxy with multiple IPs and SSL?

I would like to setup nginx reverse proxy with multiple domains and an IP for each of them to use different SSL Certs. I run Ubuntu as OS which is installed on a KVM/Qemu VM. As I understand nginx, ...