500 internal server error nginx/1.0.15

500 internal server error nginx/1.0.15

a padding to disable MSIE and Chrome friendly error page -->" CRLF ; static "" CRLF "500 Internal Server Error" CRLF. Stack Overflow for Teams – Start collaborating and sharing organizational knowledge. (spacewander); Change: all features of nginx-1.18.0 are inherited, i.e., (wangfakang); Bugfix: fixed compilation error of dyups module.

watch the thematic video

❤🧡💛💚💙💜🤎🖤🤍

500 internal server error nginx/1.0.15 - consider, that

%%PREFIX%%

There are some things to note when configuring a 404 error page in the Nginx server

One day after the change of VPS, I saw a large number of "soft 404" errors in the console of Google administrator tools. After looking up some information, I found that it was the wrong way to configure the 404 page under Nginx that caused the error. Record 1 correct 404 page configuration method under Nginx.

404 is a corresponding code that means "page could not be found "(Page Not Found).

So instead of returning 404(Page Not Found) code for those URL that don't exist, the server returns 200(OK) code, which is not normal.

Later, I saw this paragraph in other search results


After watching an Epiphany, because my 404 there are pictures and CSS custom page, the images with CSS are relative path (eg. / xxx xxx) is written on the page, so in order to let the site can see pictures of 404 pages, I will define the 404 pages in Nginx into an absolute path (eg. / / www. slyar. com/xxx/xxx), because the page as the external page, so will return 200 code, This results in the "soft 404" error.

It is easy to know the mistake. Define the path of a 404 page as a relative path, and for images and CSS, just use the absolute path within the page.

The correct 404 page definition method under Nginx:

1. VIM edits the Nginx configuration file, changes the vhosts configuration file separately, and changes nginx.conf configuration file directly

or

2. Specify a 404 page with a relative path

3. Save and exit wq and reload Nginx

4. Recheck 1 for a nonexistent page to see if 404 is returned

5. Hide the Nginx error page and the version number on Header
Nginx will display the version number of Nginx by default on error pages, such as 403 and 404, which is very insecure. Hackers may know how to break into your server through your version number of Nginx, because certain versions of the server program may have some vulnerabilities.

The Nginx version number usually appears in two places:

1, HTTP Header, such as Server: nginx / 1. x. Information such as x expose Web server software name and version number

2. On error pages such as 403 and 404, Nginx 1.x.x and other version information will be displayed by default

Hiding Nginx version number is very simple, the authorities have given a very good solution, using server_tokens (Whether to send Nginx Nginx number in error error and Server header)

Open the configuration file Nginx.conf and add the following parameters to the http1 section

After that, nginx-s reload overloads the Nginx configuration so that the version number of Nginx can be hidden. You can test yourself using curl.


awk'/^tcp/{++S[$NF]} END {for(a in S) print a, S[a]}' TIME_WAIT 1 ESTABLISHED 4 [[email protected] cache]# ll Total amount 8 drwx------. 3 coovanftp coovanftp 4096 November 20 11:55 a drwx------. 3 coovanftp coovanftp 4096 November 20 11:54 b

Finally attach the configuration

user coovanftp coovanftp; worker_processes 8; error_log logs/error.log crit; worker_rlimit_nofile 65535; events { use epoll; worker_connections 65535; } http { include mime.types; default_type application/octet-stream; log_format main'$remote_addr-$remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; server_tokens off; access_log logs/access.The default load balancing method is polling. The server instruction in the upstream module is used to specify the name and parameters of the backend server. The name of the server can be Is a domain name, an IP address, port number or UNIX Socket. #In the server{..} virtual host, you can set up a reverse proxy upstream server cluster through proxy_pass and fastcgi_pass instructions # proxy_set_header instruction is used to add the specified header information when initiating a request to the back-end WEB server of the reverse proxy #When there are multiple domain-based virtual hosts on the back-end WEB server, the header header information Host must be added to specify the requested domain name, so that the back-end server can identify which virtual host is the reverse proxy access request To deal with #After using the reverse proxy, the back-end web server cannot directly obtain the user's real ip with the $_SERVER['REMOTE_ADDR'] variable, and the ip of the load balancer will be obtained through $_SERVER['REMOTE_ADDR']. At this time , It is necessary to add the Header header X-Forwarded-For through Nginx reverse proxy, so that the back-end web server can obtain the user's real IP through $_SERVER['HTTP_X_FORWARDED_FOR'] #nginx proxy_cache related instruction set # 1.proxy_cache: This instruction is used to set which cache area will be used # 2.proxy_cache_path: This instruction is used to set the storage path of cache files #Example: proxy_cache_path/web/server1 levels=1:2 keys_zone=cache_one:500m inactive=1d max_size=30g # This command can only be configured in the http tag, levels specifies that the cache space has two levels of hash directories, the first level is 1 letter, and the second level is 2 letters; The # keys_zone parameter is used to name this cache area, 500m refers to the memory cache space size of 500MB; inactive 1d means that if the cached data is not accessed within 1 day, it will be deleted; max_size 30g refers to the hard disk cache space of 30GB #3.proxy_cache_methods: This directive is used to set cached http methods, the get and head are cached by default, and the post is not cached #4.proxy_cache_min_uses: This instruction is used to set the minimum number of uses of the cache, the default is 1 #5.proxy_cache_valid: This instruction is used to set different cache times for different URLs that return status codes upstream iis{ server 192.168.0.21; } server { listen 80; server_name 192.168.0.21; location/{ index index.php index.html; proxy_pass http://iis; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $remote_addr; proxy_next_upstream http_502 http_504 error timeout invalid_header; proxy_cache cache_one; proxy_cache_valid 200 5m; proxy_cache_valid 304 5m; proxy_cache_valid 301 302 1h; proxy_cache_valid any 5m; proxy_cache_key http://$host$uri$is_args$args; } error_page 500 502 503 504/50x.html; location =/50x.html { root/usr/share/nginx/html; } } }