HOW TO Solve Common NGINX Problems

Fist of all, I write this article to collect all the ways which I used for solved most common Nginx problems during VPS / Server setup process. That mean this post will continuing update until I move to another web server softwares for example: lighttpd, litespeed, ...
If you’re new or old to Nginx, you’ll facing with some problems, some of them can be solve easy with simple steps but we spend a lot time to research and fix it. Why? Did you know? The most frequent issue we see happens when someone attempts to just copy and paste a configuration snippet from some other guide. It’s the answer. Don’t follow the guides out there unless you can understand what they’re trying to do and can clean it up. You’ll solving almost common problems of Nginx.

Your Issue Isn’t Listed!

Yes, this post is not NGINX Problems Dictionary, you can’t find all at here. But don’t be shy, let’s commenting about your problem, maybe it’s can be solve soon with my knowledge or our audience.

HOW TO Solve Common NGINX Problems

400 Bad Request – Request Header Or Cookie Too Large

That’s strange error, someone thinks it’s browser error because restart your browser fixes this issue. If you face this error screen too frequently, your Nginx configuration has problem.

How to fix it

Try increasing the large_client_header_buffers directive in nginx

server {
...
large_client_header_buffers 4 16k;
... 
}

nginx: [emerg] “location” directive is not allowed here

The server directive has to be in the http directive. It should not be outside of it.

Let’s double check your nginx configuration to make sure it correctly.

Incase if you need detailed information, refer this.

403 Forbidden

Ahh, it’s very common error. Everybody has confused with this and how to fixed it. I’ve mentioned about 403 Forbidden on WordPress before, let’s read it before read on, maybe it’s help you fix this issue.

How to fix it

403 response headers are intentionally returned in many cases such as:

  • Nginx hasn’t permission to read / write to your website files
  • User tries to access a directory but autoindex is set to off.
Turn on autoindex
location /path/to/website/folder {
...
autoindex on;
... 
}
Set folder and files permission correctly or change owner of them

In Ubuntu, the default group and user for web server is www-data, re-check it and set it correctly. Before change it, you can find the information of nginx process:

$ ps -ef | grep nginx
www-data 14132 14130 0 16:06 ? 00:00:00 nginx: worker process

On Arch Linux, it’s http:http

3 Comments

  1. I am getting a nginx.exe was unable to start correctly while shutdown my laptop in windows7 .pls help me sir…

    • Sorry, I’m using Linux for 10 years ago and I don’t know too much about the Windows, you can find the answer in Nginx community for the support.

  2. Thanks for the info, the fix to “large_client_header_buffers” worked.


Add a Comment

Your email address will not be published. Required fields are marked *

Comment *
Name *
Email *
Website

This site uses Akismet to reduce spam. Learn how your comment data is processed.