Home nginx Nginx configuration 404

Nginx configuration 404

Author

Date

Category

I must say that with the configuration server superficially familiar, the problem may be trifling. But I will be extremely grateful for the help. I went to the site on Oleh Dopilka design and minor improvements. The server is running a bunch of nginx and php-fpm. Situation (sorry for the design, the reputation of the links is not enough):

- when linking http://blabla.ru/blublu.php - goes on
  http://blabla.ru/404.php
 - when linking http://blabla.ru/blublu.pdf - nothing
  occurs and displays the main http://blabla.ru, although in the address
  line http://blabla.ru/blublu.pdf
 - when linking http://blabla.ru/asfasflkjw1312kl (i.e. driven into
  absolute nonsense) - nothing happens and the name of the main
  http://blabla.ru, although in the address bar http://blabla.ru/asfasflkjw1312kl

As I understand it at the request of any non-existing link, whether it is a reference to a file or to an absolute nonsense, must be either pereadrecsatsiya on 404.php. But this is not happening. How to fix? nginx setup enclose. Thanks in advance for your answer.

user www-data;
worker_processes 4;
timer_resolution 100ms;
worker_rlimit_nofile 8192;
worker_priority -5; # Uvelichitvvaem priority
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
Events {
  Worker_Connections 1024;
}
http {
  server_tokens off;
  include /etc/nginx/mime.types;
  access_log /var/log/nginx/access.log;
  Sendfile ON;
  keepalive_timeout 65000;
  tcp_nodelay on;
  client_max_body_size 50m;
  gzip on;
  gzip_min_length 1100;
  gzip_disable "msie6"; # Faster, but only works on newer versions of nginx
  #gzip_disable "MSIE [1-6] \. (* SV1?!.)";
  gzip_proxied any;
  gzip_comp_level 4;
  gzip_types text / plain text / css application / x-javascript text / xml application / xml $
  gzip_vary on;
  include /etc/nginx/conf.d/*.conf;
  include / etc / nginx / sites-enabled / *;
}

The file configuration of the sites-enabled:

server {
 LISTEN 80;
 server_name www.blabla.ru;
 301 return http: //blabla.ru$request_uri;
 }
Server {
 LISTEN 80;
 server_name XXX.XX.XXX.X;
 301 return http: //blabla.ru$request_uri;
 }
Server {
 LISTEN 80;
 server_name blabla.ru;
 #return 301 $ scheme: //blabla.ru$request_uri;
 server_name xxx.xx.xxx.x;
 root /home/hosting/blabla.ru/www/;
 index index.php index.htm index.html;
 error_page 404 /404.php;
 #error_page 403,404;
 access_log /home/hosting/blabla.ru/log/nginx/access.log;
 error_log /home/hosting/blabla.ru/log/nginx/error.log;
location / {
 if (! -e $ request_filename) {
 rewrite ^ / /index.php?$query_string (*.); # 301 redirect
 }
 }
location / r {
 rewrite ^ / r /(.*) /r.php?rub=$1; # 301 redirect
 }
location / category {
 rewrite ^ / category /(.*) /category.php?rub=$1; # 301 redirect
 }
location / article {
 rewrite ^ / article /(.*) /article.php?rub=$1; # 301 redirect
 }
location / pages {
 rewrite ^ / pages /(.*) /pages.php?rub=$1; # 301 redirect
 }
location / author {
 rewrite ^ / author /(.*) /author.php?rub=$1; # 301 redirect
 }
location / user {
 rewrite ^ / user /(.*) /user.php?rub=$1; # 301 redirect
 }
location / register {
 rewrite ^ / register /(.*) /register.php?rub=$1; # 301 redirect
 }
location / main {
 rewrite ^ / main /(.*) /main.php?rub=$1; # 301 redirect
 }
location / profile {
 rewrite ^ / profile /(.*) /profile.php?rub=$1; # 301 redirect
 }
location / logout {
 rewrite ^ / logout /(.*) /logout.php; # 301 redirect
 }
location ~ * ^ + (js | css | png | jpg | jpeg | gif | ico).. $ {
 access_log off;
 expires max;
 }
location ~ \ .php $ {
 (. *) # Fastcgi_split_path_info ^ (.. + \ Php) $;
 # Fastcgi_pass 127.0.0.1:9000;
 fastcgi_pass unix: /var/run/php5-fpm.sock;
 fastcgi_index index.php;
 fastcgi_param DOCUMENT_ROOT /home/hosting/blabla.ru/www;
 fastcgi_param SCRIPT_FILENAME /home/hosting/blabla.ru/www$fastcgi_script_name;
 fastcgi_param PATH_TRANSLATED /home/hosting/blabla.ru/www$fastcgi_script_name; 
include fastcgi_params;
 fastcgi_param QUERY_STRING $ query_string;
 fastcgi_param REQUEST_METHOD $ request_method;
 fastcgi_param CONTENT_TYPE $ content_type;
 fastcgi_param CONTENT_LENGTH $ content_length;
 fastcgi_intercept_errors on;
 fastcgi_ignore_client_abort off;
 fastcgi_connect_timeout 60000;
 fastcgi_send_timeout 180000;
 fastcgi_read_timeout 180000;
 fastcgi_buffer_size 128k;
 fastcgi_buffers 4 256k;
 fastcgi_busy_buffers_size 256k;
 fastcgi_temp_file_write_size 256k;
 }
location = /favicon.ico {
 log_not_found off;
 access_log off;
 }
location = /robots.txt {
 allow all;
 log_not_found off;
 access_log off;
 }
location ~ /\.ht {
 deny all;
 }
 location / phpmyadmin {
 #auth_basic "Enter Super Secret password!";
 #auth_basic_user_file /home/hosting/.htpasswd;
 root / usr / share /;
 index index.php index.html index.htm;
 location ~ ^ / phpmyadmin / (. + \. php) $ {
 try_files $ uri = 404;
 root / usr / share /;
 # Fastcgi_pass 127.0.0.1:9000;
 fastcgi_pass unix: /var/run/php5-fpm.sock;
 fastcgi_index index.php;
 fastcgi_param SCRIPT_FILENAME $ request_filename;
 fastcgi_connect_timeout 60000;
 fastcgi_send_timeout 180000;
 fastcgi_read_timeout 180000;
 include / etc / nginx / fastcgi_params;
 }
 location ~ * ^ / phpmyadmin / (+ \ (jpg |.. jpeg | gif | css | png | js | ico | html | xml | txt)) $ {
 root / usr / share /;
 }
 }
 location / phpMyAdmin {
 rewrite ^ / * / phpmyadmin last;
 }
 }

Answer 1, Authority 100%

Now this block “triggered” to requests /blublu.pdf (I understand that such a file in the root of the site do not have), and / asfasflkjw1312kl , transferring a request to appeal to /index.php :

location / {
 if (! -e $ request_filename) {
 rewrite ^ / /index.php?$query_string (*.); # 301 redirect
 }
}

If you do not want this behavior, simply comment out the block.

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions