Have nginx access_log and error_log log to STDOUT and STDERR of master process

Edit: it seems nginx now supports error_log stderr; as mentioned in Anon’s answer. You can send the logs to /dev/stdout. In nginx.conf: daemon off; error_log /dev/stdout info; http { access_log /dev/stdout; … } edit: May need to run ln -sf /proc/self/fd /dev/ if using running certain docker containers, then use /dev/fd/1 or /dev/fd/2

How can I tell if my server is serving GZipped content?

It looks like one possible answer is, unsurprisingly, curl: $ curl http://example.com/ –silent –write-out “%{size_download}\n” –output /dev/null 31032 $ curl http://example.com/ –silent -H “Accept-Encoding: gzip,deflate” –write-out “%{size_download}\n” –output /dev/null 2553 In the second case the client tells the server that it supports content encoding and you can see that the response was indeed shorter, compressed.

What does upstream mean in nginx?

It’s used for proxying requests to other servers. An example from http://wiki.nginx.org/LoadBalanceExample is: http { upstream myproject { server 127.0.0.1:8000 weight=3; server 127.0.0.1:8001; server 127.0.0.1:8002; server 127.0.0.1:8003; } server { listen 80; server_name www.domain.com; location / { proxy_pass http://myproject; } } } This means all requests for / go to the any of the servers … Read more

nginx missing sites-available directory

Well, I think nginx by itself doesn’t have that in its setup, because the Ubuntu-maintained package does it as a convention to imitate Debian’s apache setup. You could create it yourself if you wanted to emulate the same setup. Create /etc/nginx/sites-available and /etc/nginx/sites-enabled and then edit the http block inside /etc/nginx/nginx.conf and add this line … Read more

Configure nginx with multiple locations with different root folders on subdomain

You need to use the alias directive for location /static: server { index index.html; server_name test.example.com; root /web/test.example.com/www; location /static/ { alias /web/test.example.com/static/; } } The nginx wiki explains the difference between root and alias better than I can: Note that it may look similar to the root directive at first sight, but the document … Read more

Nginx location priority

From the HTTP core module docs: Directives with the “=” prefix that match the query exactly. If found, searching stops. All remaining directives with conventional strings. If this match used the “^~” prefix, searching stops. Regular expressions, in the order they are defined in the configuration file. If #3 yielded a match, that result is … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)