<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://training-course-material.com/index.php?action=history&amp;feed=atom&amp;title=Troubleshooting</id>
	<title>Troubleshooting - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://training-course-material.com/index.php?action=history&amp;feed=atom&amp;title=Troubleshooting"/>
	<link rel="alternate" type="text/html" href="https://training-course-material.com/index.php?title=Troubleshooting&amp;action=history"/>
	<updated>2026-04-22T15:54:31Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://training-course-material.com/index.php?title=Troubleshooting&amp;diff=23947&amp;oldid=prev</id>
		<title>Cesar Chew at 17:32, 24 November 2014</title>
		<link rel="alternate" type="text/html" href="https://training-course-material.com/index.php?title=Troubleshooting&amp;diff=23947&amp;oldid=prev"/>
		<updated>2014-11-24T17:32:28Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Cat|Nginx}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;slideshow style=&amp;quot;nobleprog&amp;quot; headingmark=&amp;quot;⌘&amp;quot; incmark=&amp;quot;…&amp;quot; scaled=&amp;quot;true&amp;quot; font=&amp;quot;Trebuchet MS&amp;quot; &amp;gt;&lt;br /&gt;
;title: Troubleshooting&lt;br /&gt;
;author: Bernard Szlachta (NobleProg Ltd)&lt;br /&gt;
&amp;lt;/slideshow&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Troubleshooting ⌘===&lt;br /&gt;
* Before you assume it&amp;#039;s an nginx problem, take a step back and look at the issue&lt;br /&gt;
* Automated script to help problem diagnosis - What&amp;#039;s Wrong?&lt;br /&gt;
:* https://github.com/BashtonLtd/whatswrong&lt;br /&gt;
&lt;br /&gt;
=== nginx Troubleshooting ⌘===&lt;br /&gt;
* Always syntax check your config&lt;br /&gt;
 service nginx configtest&lt;br /&gt;
* Check the error log&lt;br /&gt;
:* By default, /var/log/nginx/error_log&lt;br /&gt;
&lt;br /&gt;
=== nginx error logs ⌘===&lt;br /&gt;
* Can sometimes be a little cryptic&lt;br /&gt;
* Google helps of course..&lt;br /&gt;
&lt;br /&gt;
=== Common errors (1) ⌘===&lt;br /&gt;
;&lt;br /&gt;
 2012/11/29 06:31:42 [error] 2589#0: *6437 client intended to send too &lt;br /&gt;
 large body: 13106010 bytes, client: 127.0.0.1, server: , request: &lt;br /&gt;
 &amp;quot;POST /upload/ HTTP/1.1&amp;quot;, host: &amp;quot;www.example.com&amp;quot;, referrer: &lt;br /&gt;
 &amp;quot;http://www.example.com/file_upload/&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Client attempted to upload a file bigger than the maximum POST size&lt;br /&gt;
&lt;br /&gt;
=== Common errors (1) ⌘===&lt;br /&gt;
;&lt;br /&gt;
 2012/11/29 06:31:42 [error] 2589#0: *6437 client intended to send too &lt;br /&gt;
 large body: 13106010 bytes, client: 127.0.0.1, server: , request: &lt;br /&gt;
 &amp;quot;POST /upload/ HTTP/1.1&amp;quot;, host: &amp;quot;www.example.com&amp;quot;, referrer: &lt;br /&gt;
 &amp;quot;http://www.example.com/file_upload/&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Common errors (2) ⌘===&lt;br /&gt;
;&lt;br /&gt;
 2012/10/14 19:51:22 [emerg] 3969#0: &amp;quot;proxy_pass&amp;quot; cannot have &lt;br /&gt;
 URI part in location given by regular expression, or inside &lt;br /&gt;
 named location, or inside &amp;quot;if&amp;quot; statement, or inside &lt;br /&gt;
 &amp;quot;limit_except&amp;quot; block in /etc/nginx/conf.d/proxy.conf:16&lt;br /&gt;
&lt;br /&gt;
=== Common errors (2)⌘===&lt;br /&gt;
;&lt;br /&gt;
 2012/10/14 19:51:22 [emerg] 3969#0: &amp;quot;proxy_pass&amp;quot; cannot have &lt;br /&gt;
 URI part in location given by regular expression, or inside &lt;br /&gt;
 named location, or inside &amp;quot;if&amp;quot; statement, or inside &lt;br /&gt;
 &amp;quot;limit_except&amp;quot; block in /etc/nginx/conf.d/proxy.conf:16&lt;br /&gt;
&lt;br /&gt;
* nginx won&amp;#039;t start to to configuration syntax error&lt;br /&gt;
* Line containing error shown&lt;br /&gt;
* If you attempted to reload nginx with this config, it will continue to run with the old config&lt;br /&gt;
&lt;br /&gt;
=== Common errors (3) ⌘===&lt;br /&gt;
;&lt;br /&gt;
 2012/10/14 18:46:54 [emerg] 2593#0: unknown directive &lt;br /&gt;
 &amp;quot;client_body_temp_path&amp;quot; in /etc/nginx/conf.d/vhost.conf:6&lt;br /&gt;
&lt;br /&gt;
=== Common errors (3) ⌘===&lt;br /&gt;
;&lt;br /&gt;
 2012/10/14 18:46:54 [emerg] 2593#0: unknown directive &lt;br /&gt;
 &amp;quot;client_body_temp_path&amp;quot; in /etc/nginx/conf.d/vhost.conf:6&lt;br /&gt;
&lt;br /&gt;
* client_body_temp_path is actually a valid directive&lt;br /&gt;
* .. but it&amp;#039;s being used in the wrong place&lt;br /&gt;
* Because nginx is modular, each module&amp;#039;s directives are known only inside the section that module configures&lt;br /&gt;
&lt;br /&gt;
=== Common errors (4) ⌘===&lt;br /&gt;
;&lt;br /&gt;
 2012/10/16 20:56:31 [emerg] 3039#0: &amp;quot;try_files&amp;quot; directive is not allowed&lt;br /&gt;
 here in /opt/nginx/conf/vhost.conf:16&lt;br /&gt;
&lt;br /&gt;
=== Common errors (4) ⌘===&lt;br /&gt;
;&lt;br /&gt;
 2012/10/16 20:56:31 [emerg] 3039#0: &amp;quot;try_files&amp;quot; directive is not allowed&lt;br /&gt;
 here in /etc/nginx/conf.d/vhost.conf:16&lt;br /&gt;
&lt;br /&gt;
* nginx can sometimes hint when you&amp;#039;ve used something valid for the module, but in the wrong place&lt;br /&gt;
&lt;br /&gt;
=== Common errors (5) ⌘===&lt;br /&gt;
;&lt;br /&gt;
 2012/10/16 20:56:42 [emerg] 3043#0: host not found in upstream &amp;quot;tickets.&lt;br /&gt;
 example.com&amp;quot; in /opt/nginx/conf.d/proxy.conf:22&lt;br /&gt;
&lt;br /&gt;
=== Common errors (5) ⌘===&lt;br /&gt;
;&lt;br /&gt;
 2012/10/16 20:56:42 [emerg] 3043#0: host not found in upstream &amp;quot;tickets.&lt;br /&gt;
 example.com&amp;quot; in /opt/nginx/conf.d/proxy.conf:22&lt;br /&gt;
&lt;br /&gt;
* Your configuration is valid, but there is a DNS problem looking up&lt;br /&gt;
  tickets.example.com&lt;br /&gt;
&lt;br /&gt;
=== Common errors (6) ⌘===&lt;br /&gt;
;&lt;br /&gt;
 2012/10/29 18:59:26 [emerg] 2287#0: unexpected &amp;quot;}&amp;quot; in /etc/nginx/conf.d/&lt;br /&gt;
 vhost.conf:40&lt;br /&gt;
&lt;br /&gt;
=== Common errors (6) ⌘===&lt;br /&gt;
;&lt;br /&gt;
 2012/10/29 18:59:26 [emerg] 2287#0: unexpected &amp;quot;}&amp;quot; in /etc/nginx/conf.d/&lt;br /&gt;
 vhost.conf:40&lt;br /&gt;
&lt;br /&gt;
* Simple syntax error&lt;br /&gt;
* Too many closing brackets&lt;br /&gt;
=== Common errors (7) ===&lt;br /&gt;
;&lt;br /&gt;
 2012/10/29 18:59:26 [emerg] 2287#0: unexpected end of file, expecting &amp;quot;}&amp;quot; &lt;br /&gt;
 in /etc/nginx/conf.d/ vhost.conf:40&lt;br /&gt;
&lt;br /&gt;
=== Common errors (7) ⌘===&lt;br /&gt;
;&lt;br /&gt;
 2012/10/29 18:59:26 [emerg] 2287#0: unexpected end of file, expecting &amp;quot;}&amp;quot; &lt;br /&gt;
 in /etc/nginx/conf.d/ vhost.conf:40&lt;br /&gt;
&lt;br /&gt;
* Simple syntax error&lt;br /&gt;
* Insufficient closing brackets&lt;br /&gt;
&lt;br /&gt;
=== Debugging with custom logs ⌘===&lt;br /&gt;
* Not sure if a section of config is getting called, or what a variable is set to?&lt;br /&gt;
* Log data into the access logs with the `log_format` directive&lt;br /&gt;
&lt;br /&gt;
=== Debugging with custom logs example ⌘===&lt;br /&gt;
;&lt;br /&gt;
 http {&lt;br /&gt;
  log_format sentlog &amp;#039;[$time_local] &amp;quot;$request&amp;quot; $status $body_bytes_sent &amp;#039;;&lt;br /&gt;
  log_format imagelog &amp;#039;[$time_local] $image_file $image_type &amp;#039; &amp;#039;$body_bytes_sent $status&amp;#039;;&lt;br /&gt;
  log_format authlog &amp;#039;[$time_local] $remote_addr $remote_user &amp;#039; &amp;#039;&amp;quot;$request&amp;quot; $status&amp;#039;;&lt;br /&gt;
  server {&lt;br /&gt;
    server_name .example.com;&lt;br /&gt;
    root /home/www;&lt;br /&gt;
    location / {&lt;br /&gt;
      access_log logs/example.com-access.log combined;&lt;br /&gt;
      access_log logs/example.com-root_access.log sentlog;&lt;br /&gt;
      rewrite ^/(.*)\.(png|jpg|gif)$ /images/$1.$2;&lt;br /&gt;
      set $image_file $1;&lt;br /&gt;
      set $image_type $2;&lt;br /&gt;
    }&lt;br /&gt;
    location /images {&lt;br /&gt;
      access_log logs/example.com-images_access.log imagelog;&lt;br /&gt;
    }&lt;br /&gt;
    location /auth {&lt;br /&gt;
      auth_basic &amp;quot;authorized area&amp;quot;;&lt;br /&gt;
      auth_basic_user_file conf/htpasswd;&lt;br /&gt;
      deny all;&lt;br /&gt;
      access_log logs/example.com-auth_access.log authlog;&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
== Miscellaneous ⌘==&lt;br /&gt;
=== Be careful what you believe on the Internet ⌘===&lt;br /&gt;
* nginx still relatively young&lt;br /&gt;
* There have been many changes to configuration syntax and features since release&lt;br /&gt;
* Many blog/forum posts you will find via Google telling you how to do something are outdated or just plain wrong&lt;br /&gt;
&lt;br /&gt;
=== Common mis-use ⌘===&lt;br /&gt;
* Commonly seen on forums/blogs:&lt;br /&gt;
 location / {&lt;br /&gt;
  if (!-f $request_filename) {&lt;br /&gt;
    include fastcgi_params;&lt;br /&gt;
    proxy_pass 127.0.0.1:8000;&lt;br /&gt;
    break;&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== Common mis-use - the right way ⌘===&lt;br /&gt;
* A better performing way to achieve the same result:&lt;br /&gt;
 location / {&lt;br /&gt;
  try_files $uri $uri/ @proxy;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 location @proxy {&lt;br /&gt;
  proxy_pass 127.0.0.1:8000;&lt;br /&gt;
 }&lt;br /&gt;
=== More commonly seen bad advice ⌘===&lt;br /&gt;
;&lt;br /&gt;
 server {&lt;br /&gt;
  server_name .example.com;&lt;br /&gt;
  root /var/www/html;&lt;br /&gt;
  if ($host ~* ^example\.com) {&lt;br /&gt;
    rewrite ^/(.*)$ http://www.example.com/$1 redirect;&lt;br /&gt;
  }&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== The right way ⌘===&lt;br /&gt;
;&lt;br /&gt;
 server {&lt;br /&gt;
  server_name example.com;&lt;br /&gt;
  return 301 http://www.example.com;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
=== In-place upgrades ⌘===&lt;br /&gt;
* nginx has a nice feature to switch binaries while running&lt;br /&gt;
* installing an upgraded package leaves the old version of nginx running&lt;br /&gt;
* simply run `service nginx upgrade` to switch to the new version with 0 downtime&lt;br /&gt;
&lt;br /&gt;
=== nginx status module ⌘===&lt;br /&gt;
* nginx has module which can provide status details vi a URL&lt;br /&gt;
 location /nginx_status {&lt;br /&gt;
  stub_status on;&lt;br /&gt;
  access_log off;&lt;br /&gt;
  allow 127.0.0.1;&lt;br /&gt;
  deny all;&lt;br /&gt;
 }&lt;br /&gt;
=== Status module output ⌘===&lt;br /&gt;
;&lt;br /&gt;
 $ curl -s http://localhost/nginx_status&lt;br /&gt;
 Active connections: 2532&lt;br /&gt;
 server accepts handled requests&lt;br /&gt;
 1476737983 1476737983 3553635810&lt;br /&gt;
 Reading: 93 Writing: 13 Waiting: 2426&lt;/div&gt;</summary>
		<author><name>Cesar Chew</name></author>
	</entry>
</feed>