LINUX.ORG.RU
ФорумAdmin

Переодически вылетает ошибка 502 - nginx

 ,


1

1

Доброго дня. В один день вдруг началась такая проблема. При осуществление действий от имени авторизованного пользователя (выставление статей на сайт) появляется ошибка 502. Не всегда, через раз. После каких именно действий она появляется, так и не смог выяснить. После чего такое произошло тоже. Ниже конфиги nginx.cfg

user nginx nobody;                  
worker_processes	16;               

error_log /var/log/nginx/error_log notice;

events {
##  worker_connections	2048;
  worker_connections	204800;
  use epoll;               
}

#worker_rlimit_nofile	32768;
worker_rlimit_nofile	327680;

http {
    include /etc/nginx/mime.types;
    default_type application/octet-stream;

upstream fpm-sock {
 server unix:/var/run/php5-fpm.sock;
 }

    log_format main
    '$remote_addr - $remote_user [$time_local] '
    '"$request" $status $bytes_sent '           
    '"$http_referer" "$http_user_agent" '       
    '"$gzip_ratio"';                            


#geoip_country	/usr/share/GeoIP/GeoIP.dat;
#geoip_city	/usr/share/GeoIP/GeoIPCity.dat;
#geoip_org	/usr/share/GeoIP/GeoIPISP.dat;

## Size Limits

keepalive_timeout 6000;

output_buffers 32 512k;
sendfile_max_chunk 128k;
postpone_output 1460;
server_names_hash_bucket_size 64;


client_max_body_size 100m;

## General Options
    ignore_invalid_headers	on;
    sendfile	on;
upload_progress uploads 1m;

## TCP options 
    tcp_nodelay	on;
    tcp_nopush	on;
    reset_timedout_connection on;

## Compression
    gzip		on;
    gzip_buffers	16 8k;
    gzip_comp_level	5;
    gzip_http_version	1.0;
    gzip_min_length	1000;
    gzip_types		text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
    gzip_vary		on;
    gzip_static		on;
    gzip_proxied	any;
    gzip_disable	msie6;

    index index.php index.html;

    include hosts/mysite.ru.conf;
...(здесь ещё 12 сайтов)
    include hosts/mysite-n.ru.conf;

}# end of http


Было keepalive_timeout 600; Сделал 1000, ошибка при публикации материалов стала появлятся крайне редко, но теперь вылезет при просмотре сайта у всех пользователей, опять же иногда, бывает при клике на фото, бывает при просмотре материала.

mysite.ru.conf (конфиг сайта)

    server {
	listen ***.**.**.**;
	server_name mysite.ru;
	#limit_conn one 60;
	access_log /var/log/nginx/mysite.access_log main;
	error_log /var/log/nginx/mysite.error_log info;  

	root /var/www/mysite.ru/htdocs;


	## www. redirect
	if ($host ~* ^(www\.)(.+)) {
	  set $rawdomain $2;
	  rewrite ^/(.*)$  http://$rawdomain/$1 permanent;
	}

	## rewrite rules for old site
	rewrite ^/art([0-9]*)\.html? /node/$1 permanent;
	rewrite ^/topic([0-9]*)\.html? /taxonomy/term/$1 permanent;
	rewrite ^/topic([0-9]*)-([0-9]*)\.html? /taxonomy/term/$1?page=$2 permanent;

	rewrite ^/reviews\.php /taxonomy/term/19 permanent;

	rewrite ^/theme([0-9]*)\.html? /old/theme.php?id=$1;
	rewrite ^/delivery_full_([0-9]*)\.html? /old/delivery.php?d=$1;
	rewrite ^/review([0-9]*)\.html? /old/review.php?id=$1;
	rewrite ^/show_review\.php /old/review.php;
	rewrite ^/archive\.php /archive/today permanent;

	rewrite ^/yandex.news/yandex.phtm /yandex.xml;

	rewrite ^/img/([^\.]*\.(jpg|gif)) /sites/default/files/img/$1 permanent;

	rewrite ^/info/(.*)\.htm /info/index.php?id=$1;
	rewrite ^/info/?$ /info/index.php;
	rewrite ^/info/sitemap.xml /info/sitemap.php;
	rewrite ^/egadget([1-9])\.xml /egadget/$1/feed permanent;

	if ($request_uri ~* "^/show_article\.php\?id=([0-9]*)") {
	  set $q $1;
	  set $args "";
	  rewrite ^\/.*$ /node/$q permanent;
	}

#        location ~* ^/(bank|nojob|pkuda|politi[ck]a|shkola)/? {
        location ~* ^/(nojob|pkuda|shkola)/? {
	proxy_pass   [url]http://old.mysite.ru;[/url]
	    proxy_redirect default;
	    proxy_set_header Host $host;
	    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }

        location ~* ^/(medi[ck])/? {
            proxy_pass   [url]http://med.mysite.ru;[/url]
            proxy_redirect default;
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }


	## 6.x starts
	location / {
	  #rewrite ^/(.*)/$ /$1 permanent; # remove trailing slashes - disabled
	  try_files $uri @cache;
	}

	location @cache {
	  if ( $request_method !~ ^(GET|HEAD)$ ) {
	    return 405;
	  }

	  if ($http_cookie ~ "DRUPAL_UID") {
	    return 405;
	  }

	  error_page 405 = @drupal;

	  add_header Expires epoch;
	  add_header Cache-Control "must-revalidate, post-check=0, pre-check=0";
	  try_files /cache/normal/$host${uri}_$args.html @drupal;
	}

	location @drupal {
	  ###
	  ### now simplified to reduce rewrites
	  ###
	  rewrite ^/(.*)$  /index.php?q=$1 last;
	}

	location ~* (/\..*|settings\.php$|\.(htaccess|engine|inc|info|ini|install|module|profile|pl|po|pot|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(Entries.*|Repository|Root|Tag|Template))$ {
	  deny all;
	}

	location ~* /files/.*\.php$ {
	  return 444;
	}
	location ~* /themes/.*\.php$ {
	  return 444;
	}

	location ~* \.php$ {
	  try_files $uri @drupal;       #check for existence of php file
	  fastcgi_pass		fpm-sock;
	  fastcgi_index		index.php;
	  fastcgi_param		SCRIPT_FILENAME /var/www/mysite.ru/htdocs$fastcgi_script_name;
	  include		fastcgi_params;
	}

	location ~ \.css$ {
	  if ( $request_method !~ ^(GET|HEAD)$ ) {
	    return 405;
	  }
	  if ($http_cookie ~ "DRUPAL_UID") {
	    return 405;
	  }

	  error_page 405 = @uncached;
	  access_log  off;
	  expires  max; #if using aggregator
	  try_files /cache/perm/$host${uri}_.css $uri =404;
	}
   
	location ~ \.js$ {
	  if ( $request_method !~ ^(GET|HEAD)$ ) {
	    return 405;
	  }
	  if ($http_cookie ~ "DRUPAL_UID") {
	    return 405;
	  }

	  error_page 405 = @uncached;
	  access_log  off;
	  expires  max; #if using aggregator
	  try_files /cache/perm/$host${uri}_.js $uri =404;
	}

	location ~ \.json$ {
	  if ( $request_method !~ ^(GET|HEAD)$ ) {
	    return 405;
	  }
	  if ($http_cookie ~ "DRUPAL_UID") {
	    return 405;
	  }

	  error_page 405 = @uncached;
	  access_log  off;
	  expires  max; #if using aggregator
	  try_files /cache/normal/$host${uri}_.json $uri =404;
	}

	location @uncached {
	  access_log  off;
	  expires  max; # max if using aggregator, otherwise sane expire time
	}

	location ~* /files/imagecache/ {
	  access_log         off;
	  try_files $uri @drupal;  #imagecache support - now it works
	}

	location ~* ^.+\.(jpg|jpeg|gif|png|ico)$ {
	  access_log      off;
	  expires         30d;
	  try_files $uri =404;
	}

	location ~* \.xml$ {
	  if ( $request_method !~ ^(GET|HEAD)$ ) {
	    return 405;
	  }
	  if ($http_cookie ~ "DRUPAL_UID") {
	    return 405;
	  }

	  error_page 405 = @drupal;
	  add_header Expires epoch;
	  add_header Cache-Control "must-revalidate, post-check=0, pre-check=0";
	  types { }
	  default_type application/rss+xml;
	  try_files /cache/normal/$host${uri}_.xml /cache/normal/$host${uri}_.html $uri @drupal;
	}

	location ~* /feed$ {
	  if ( $request_method !~ ^(GET|HEAD)$ ) {
	    return 405;
	  }
	  if ($http_cookie ~ "DRUPAL_UID") {
	    return 405;
	  }

	  error_page 405 = @drupal;
	  add_header Expires epoch;
	  add_header Cache-Control "must-revalidate, post-check=0, pre-check=0";
	  types { }
	  default_type application/rss+xml;
	  try_files /cache/normal/$host${uri}_.xml /cache/normal/$host${uri}_.html $uri @drupal;
	}



	location /rest/ {

		allow 127.0.0.1;
		allow ***.***.**.0/24;
		allow ***.**.***.**;
		deny  all;

		rewrite ^/(.*)$  /index.php?q=$1 break;

		include cors-nginx.conf;
		fastcgi_pass		fpm-sock;
		fastcgi_index		index.php;
		fastcgi_param		SCRIPT_FILENAME /var/www/mysite.ru/htdocs$fastcgi_script_name;
		include		fastcgi_params;

	}

    } # end of server

Последние логи php-fmp.log

[27-Apr-2016 10:53:02.134969] NOTICE: pid 9079, fpm_event_loop(), line 367: ready to handle connections
[27-Apr-2016 10:53:03.135992] DEBUG: pid 9079, fpm_pctl_perform_idle_server_maintenance(), line 379: [pool www] currently 3 active children, 29 spare children, 32 running children. Spawning rate 1

Логи в mysite.error_log выбрал разные


[B]2016/04/26 12:01:21 [info] 17564#0: *60409567 recv() failed (104: Connection reset by peer) while sending to client, client: 52.90.204.194, server: mysite.ru, request: "GET ссылка HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock", host: "mysite.ru"[/B]
насколько я понимаю это и есть та ошибка, которая мне покоя не даёт
...
2016/04/26 12:01:25 [info] 17570#0: *60408601 client 195.93.246.156 closed keepalive connection (104: Connection reset by peer)
...
2016/04/26 12:01:27 [info] 17565#0: *60409629 client 164.132.161.86 closed keepalive connection
2016/04/26 12:01:27 [info] 17564#0: *60409573 client 31.13.144.8 closed keepalive connection (104: Connection reset by peer)
2016/04/26 12:01:27 [warn] 17565#0: *60409651 an upstream response is buffered to a temporary file /var/lib/nginx/tmp/fastcgi/3/57/0000981573 while reading upstream, client: 88.198.38.111, server: mysite.ru, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "mysite.ru"
2016/04/26 12:01:28 [info] 17565#0: *60409649 client 157.55.39.40 closed keepalive connection
...

Гуглил уже неделю, в английском не силён, но переводил. Нашёл решение

http://stackoverflow.com/questions/23443398/nginx-error-connect-to-php5-fpm-s... использовал

Больше ничего не смог применить.

Какие логи и конфигу нужно, скину. Куда копать? уже сума сойду скоро.

php-fpm.conf

;;;;;;;;;;;;;;;;;;;;;
; FPM Configuration ;
;;;;;;;;;;;;;;;;;;;;;

; All relative paths in this configuration file are relative to PHP's install
; prefix (/usr/lib/php5.3). This prefix can be dynamicaly changed by using the
; '-p' argument from the command line.

; Include one or more files. If glob(3) exists, it is used to include a bunch of
; files from a glob(3) pattern. This directive can be used everywhere in the
; file.
; Relative path can also be used. They will be prefixed by:
;  - the global prefix if it's been set (-p arguement)
;  - /usr/lib/php5.3 otherwise
;include=/etc/php/fpm-php5.3/fpm.d/*.conf

;;;;;;;;;;;;;;;;;;
; Global Options ;
;;;;;;;;;;;;;;;;;;

[global]
; Pid file
; Note: the default prefix is /var/lib
; Default Value: none
; Warning: pid file is overriden by the Gentoo init script.
; FPM will refuse to start if you uncomment this settingi and make use of the
; init script. 
; pid = /var/run/php-fpm.pid

; Error log file
; Note: the default prefix is /var/lib
; Default Value: log/php-fpm.log
error_log = /var/log/php-fpm.log

; Log level
; Possible Values: alert, error, warning, notice, debug
; Default Value: notice
log_level = debug

; If this number of child processes exit with SIGSEGV or SIGBUS within the time
; interval set by emergency_restart_interval then FPM will restart. A value
; of '0' means 'Off'.
; Default Value: 0
;emergency_restart_threshold = 0

; Interval of time used by emergency_restart_interval to determine when 
; a graceful restart will be initiated.  This can be useful to work around
; accidental corruptions in an accelerator's shared memory.
; Available Units: s(econds), m(inutes), h(ours), or d(ays)
; Default Unit: seconds
; Default Value: 0
;emergency_restart_interval = 1m

; Time limit for child processes to wait for a reaction on signals from master.
; Available units: s(econds), m(inutes), h(ours), or d(ays)
; Default Unit: seconds
; Default Value: 0
;process_control_timeout = 5s

; Send FPM to background. Set to 'no' to keep FPM in foreground for debugging.
; Default Value: yes
;daemonize = yes

;;;;;;;;;;;;;;;;;;;;
; Pool Definitions ; 
;;;;;;;;;;;;;;;;;;;;

; Multiple pools of child processes may be started with different listening
; ports and different management options.  The name of the pool will be
; used in logs and stats. There is no limitation on the number of pools which
; FPM can handle. Your system will tell you anyway :)

; Start a new pool named 'www'.
; the variable $pool can we used in any directive and will be replaced by the
; pool name ('www' here)
[www]

; Per pool prefix
; It only applies on the following directives:
; - 'slowlog'
; - 'listen' (unixsocket)
; - 'chroot'
; - 'chdir'
; - 'php_values'
; - 'php_admin_values'
; When not set, the global prefix (or /usr/lib/php5.3) applies instead.
; Note: This directive can also be relative to the global prefix.
; Default Value: none
;prefix = /path/to/pools/$pool

; The address on which to accept FastCGI requests.
; Valid syntaxes are:
;   'ip.add.re.ss:port'    - to listen on a TCP socket to a specific address on
;                            a specific port;
;   'port'                 - to listen on a TCP socket to all addresses on a
;                            specific port;
;   '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
;listen = 127.0.0.1:9000
listen = /var/run/php5-fpm.sock

; Set listen(2) backlog. A value of '-1' means unlimited.
; Default Value: 128 (-1 on FreeBSD and OpenBSD)
listen.backlog = 4096
 
; List of ipv4 addresses of FastCGI clients which are allowed to connect.
; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original
; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address
; must be separated by a comma. If this value is left blank, connections will be
; accepted from any ip address.
; Default Value: any
;listen.allowed_clients = 127.0.0.1

; Set permissions for unix socket, if one is used. In Linux, read/write
; permissions must be set in order to allow connections from a web server. Many
; BSD-derived systems allow connections regardless of permissions. 
; Default Values: user and group are set as the running user
;                 mode is set to 0666
listen.owner = nobody
listen.group = nobody
listen.mode = 0666

; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
;       will be used.
user = nobody
group = nobody

; Choose how the process manager will control the number of child processes.
; Possible Values:
;   static  - a fixed number (pm.max_children) of child processes;
;   dynamic - the number of child processes are set dynamically based on the
;             following directives:
;             pm.max_children      - the maximum number of children that can
;                                    be alive at the same time.
;             pm.start_servers     - the number of children created on startup.
;             pm.min_spare_servers - the minimum number of children in 'idle'
;                                    state (waiting to process). If the number
;                                    of 'idle' processes is less than this
;                                    number then some children will be created.
;             pm.max_spare_servers - the maximum number of children in 'idle'
;                                    state (waiting to process). If the number
;                                    of 'idle' processes is greater than this
;                                    number then some children will be killed.
; Note: This value is mandatory.
;pm = static
pm = dynamic

; The number of child processes to be created when pm is set to 'static' and the
; maximum number of child processes to be created when pm is set to 'dynamic'.
; This value sets the limit on the number of simultaneous requests that will be
; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
; CGI.
; Note: Used when pm is set to either 'static' or 'dynamic'
; Note: This value is mandatory.
;pm.max_children = 16
pm.max_children = 128

; The number of child processes created on startup.
; Note: Used only when pm is set to 'dynamic'
; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
pm.start_servers = 32

; The desired minimum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
pm.min_spare_servers = 8

; The desired maximum number of idle server processes.
; Note: Used only when pm is set to 'dynamic'
; Note: Mandatory when pm is set to 'dynamic'
pm.max_spare_servers = 32
 
; The number of requests each child process should execute before respawning.
; This can be useful to work around memory leaks in 3rd party libraries. For
; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
; Default Value: 0
pm.max_requests = 500

; The URI to view the FPM status page. If this value is not set, no URI will be
; recognized as a status page. By default, the status page shows the following
; information:
;   accepted conn        - the number of request accepted by the pool;
;   pool                 - the name of the pool;
;   process manager      - static or dynamic;
;   idle processes       - the number of idle processes;
;   active processes     - the number of active processes;
;   total processes      - the number of idle + active processes.
;   max children reached - number of times, the process limit has been reached,
;                          when pm tries to start more children (works only for
;                          pm 'dynamic')
; The values of 'idle processes', 'active processes' and 'total processes' are
; updated each second. The value of 'accepted conn' is updated in real time.
; Example output:
;   accepted conn:        12073
;   pool:                 www
;   process manager:      static
;   idle processes:       35
;   active processes:     65
;   total processes:      100
;   max children reached: 1
; By default the status page output is formatted as text/plain. Passing either
; 'html' or 'json' as a query string will return the corresponding output
; syntax. Example:
;   http://www.foo.bar/status
;   http://www.foo.bar/status?json
;   http://www.foo.bar/status?html
; Note: The value must start with a leading slash (/). The value can be
;       anything, but it may not be a good idea to use the .php extension or it
;       may conflict with a real PHP file.
; Default Value: not set 
pm.status_path = /statusphpfpmbysergeyfortest.php
 
; The ping URI to call the monitoring page of FPM. If this value is not set, no
; URI will be recognized as a ping page. This could be used to test from outside
; that FPM is alive and responding, or to
; - create a graph of FPM availability (rrd or such);
; - remove a server from a group if it is not responding (load balancing);
; - trigger alerts for the operating team (24/7).
; Note: The value must start with a leading slash (/). The value can be
;       anything, but it may not be a good idea to use the .php extension or it
;       may conflict with a real PHP file.
; Default Value: not set
;ping.path = /ping
ping.path = /pingphpfpmbysergeyfortest.php

; This directive may be used to customize the response of a ping request. The
; response is formatted as text/plain with a 200 response code.
; Default Value: pong
;ping.response = pong
 
; The timeout for serving a single request after which the worker process will
; be killed. This option should be used when the 'max_execution_time' ini option
; does not stop script execution for some reason. A value of '0' means 'off'.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
;request_terminate_timeout = 0
 
; The timeout for serving a single request after which a PHP backtrace will be
; dumped to the 'slowlog' file. A value of '0s' means 'off'.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
;request_slowlog_timeout = 0
 
; The log file for slow requests
; Default Value: not set
; Note: slowlog is mandatory if request_slowlog_timeout is set
;slowlog = /var/log/php-fpm-$pool.log.slow
 
; Set open file descriptor rlimit.
; Default Value: system defined value
rlimit_files = 65535
 
; Set max core size rlimit.
; Possible Values: 'unlimited' or an integer greater or equal to 0
; Default Value: system defined value
;rlimit_core = 0
 
; Chroot to this directory at the start. This value must be defined as an
; absolute path. When this value is not set, chroot is not used.
; Note: you can prefix with '$prefix' to chroot to the pool prefix or one
; of its subdirectories. If the pool prefix is not set, the global prefix
; will be used instead.
; Note: chrooting is a great security feature and should be used whenever 
;       possible. However, all PHP paths will be relative to the chroot
;       (error_log, sessions.save_path, ...).
; Default Value: not set
;chroot = 
 
; Chdir to this directory at the start.
; Note: relative path can be used.
; Default Value: current directory or / when chroot
;chdir = /var/www
 
; Redirect worker stdout and stderr into main error log. If not set, stdout and
; stderr will be redirected to /dev/null according to FastCGI specs.
; Note: on highloaded environement, this can cause some delay in the page
; process time (several ms).
; Default Value: no
catch_workers_output = yes
 
; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
; the current environment.
; Default Value: clean env
;env[HOSTNAME] = $HOSTNAME
;env[PATH] = /usr/local/bin:/usr/bin:/bin
;env[TMP] = /tmp
;env[TMPDIR] = /tmp
;env[TEMP] = /tmp

; Additional php.ini defines, specific to this pool of workers. These settings
; overwrite the values previously defined in the php.ini. The directives are the
; same as the PHP SAPI:
;   php_value/php_flag             - you can set classic ini defines which can
;                                    be overwritten from PHP call 'ini_set'. 
;   php_admin_value/php_admin_flag - these directives won't be overwritten by
;                                     PHP call 'ini_set'
; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no.

; Defining 'extension' will load the corresponding shared extension from
; extension_dir. Defining 'disable_functions' or 'disable_classes' will not
; overwrite previously defined php.ini values, but will append the new value
; instead.

; Note: path INI options can be relative and will be expanded with the prefix
; (pool, global or /usr/lib/php5.3)

; Default Value: nothing is defined by default except the values in php.ini and
;                specified at startup with the -d argument
;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com
;php_flag[display_errors] = on
;php_admin_value[error_log] = /var/log/fpm-php.www.log
;php_admin_flag[log_errors] = on
;php_admin_value[memory_limit] = 32M

Ошибки php не изменились

[27-Apr-2016 10:53:02.134969] NOTICE: pid 9079, fpm_event_loop(), line 367: ready to handle connections
[27-Apr-2016 10:53:03.135992] DEBUG: pid 9079, fpm_pctl_perform_idle_server_maintenance(), line 379: [pool www] currently 3 active children, 29 spare children, 32 running children. Spawning rate 1

но сейчас появилась новая, наряду с ошибкой в логах nginx, php лог написал

NOTICE: pid 27839, fmp_pctl_exit(), line 70: exiting, bye-bye! - что это, не пойму.

или php.ini нужен?



Последнее исправление: MrFakir (всего исправлений: 1)

Минутка бесплатных переводов на ЛОРе.

502 Bad Gateway
The server, while acting as a gateway or proxy, received an invalid response from the upstream server it accessed in attempting to fulfill the request.

Проксирующий сервер получил неподходящий ответ в процессе удовлетворения клиента.

104: Connection reset by peer

Скорее всего скрипт по таймауту сброшен был.

Вываливай конфиг и еррорлог пыхи.
Не пытайся увеличивать таймаут пыхи больше нескольких секунд, это не решение. Надо найти тормозючий скрипт и прибиль.

Goury ★★★★★
()
Ответ на: комментарий от Goury

Дополнил конфиг php-fpm.conf в первое сообщение. или php.ini надо? Как вставить на форум сюда большой код, чтобы читалось? чёт спойлер не могу сделать.

MrFakir
() автор топика
Ответ на: комментарий от MrFakir

Нет тут ничего удобного для кода.
Вставляй как есть или ссылкой на пасты.
Конфиг надо тот, который пыха использует.

Но таки важнее для начала посмотреть на еррорлог пыхи, ибо ошибка в 502 это про неё.

Goury ★★★★★
()
Ответ на: комментарий от Goury

php_errors.log (который в /var/log/php) последняя запись 26 апреля, на другой сайт, который я отлаживал на сервере.

php_errors.log

[22-Apr-2016 12:07:37 Asia/Yekaterinburg] PHP Notice:  Undefined index: HTTP_HOST in /var/www/mysite2.su/htdocs/libraries/joomla/application/web.php on line 863
[22-Apr-2016 12:07:37 Asia/Yekaterinburg] PHP Stack trace:
[22-Apr-2016 12:07:37 Asia/Yekaterinburg] PHP   1. {main}() /var/www/mysite2.su/htdocs/index.php:0
[22-Apr-2016 12:07:37 Asia/Yekaterinburg] PHP   2. JFactory::getApplication() /var/www/mysite2.su/htdocs/index.php:46
[22-Apr-2016 12:07:37 Asia/Yekaterinburg] PHP   3. JApplicationCms::getInstance() /var/www/mysite2.su/htdocs/libraries/joomla/factory.php:125
[22-Apr-2016 12:07:37 Asia/Yekaterinburg] PHP   4. JApplicationSite->__construct() /var/www/mysite2.su/htdocs/libraries/cms/application/cms.php:404
[22-Apr-2016 12:07:37 Asia/Yekaterinburg] PHP   5. JApplicationCms->__construct() /var/www/mysite2.su/htdocs/libraries/cms/application/site.php:63
[22-Apr-2016 12:07:37 Asia/Yekaterinburg] PHP   6. JApplicationWeb->__construct() /var/www/mysite2.su/htdocs/libraries/cms/application/cms.php:105
[22-Apr-2016 12:07:37 Asia/Yekaterinburg] PHP   7. JApplicationWeb->loadSystemUris() /var/www/mysite2.su/htdocs/libraries/joomla/application/web.php:158
[22-Apr-2016 12:07:37 Asia/Yekaterinburg] PHP   8. JApplicationWeb->detectRequestUri() /var/www/mysite2.su/htdocs/libraries/joomla/application/web.php:1113
[22-Apr-2016 12:07:38 Asia/Yekaterinburg] PHP Notice:  Undefined index: HTTP_HOST in /var/www/mysite2.su/htdocs/libraries/joomla/uri/uri.php on line 85
[22-Apr-2016 12:07:38 Asia/Yekaterinburg] PHP Stack trace:
[22-Apr-2016 12:07:38 Asia/Yekaterinburg] PHP   1. {main}() /var/www/mysite2.su/htdocs/index.php:0
[22-Apr-2016 12:07:38 Asia/Yekaterinburg] PHP   2. JApplicationCms->execute() /var/www/mysite2.su/htdocs/index.php:49
[22-Apr-2016 12:07:38 Asia/Yekaterinburg] PHP   3. JApplicationSite->doExecute() /var/www/mysite2.su/htdocs/libraries/cms/application/cms.php:257
[22-Apr-2016 12:07:38 Asia/Yekaterinburg] PHP   4. JApplicationSite->initialiseApp() /var/www/mysite2.su/htdocs/libraries/cms/application/site.php:209
[22-Apr-2016 12:07:38 Asia/Yekaterinburg] PHP   5. JApplicationCms->initialiseApp() /var/www/mysite2.su/htdocs/libraries/cms/application/site.php:663
[22-Apr-2016 12:07:38 Asia/Yekaterinburg] PHP   6. JApplicationBase->triggerEvent() /var/www/mysite2.su/htdocs/libraries/cms/application/cms.php:663
[22-Apr-2016 12:07:38 Asia/Yekaterinburg] PHP   7. JEventDispatcher->trigger() /var/www/mysite2.su/htdocs/libraries/joomla/application/base.php:106
[22-Apr-2016 12:07:38 Asia/Yekaterinburg] PHP   8. JEvent->update() /var/www/mysite2.su/htdocs/libraries/joomla/event/dispatcher.php:160
[22-Apr-2016 12:07:38 Asia/Yekaterinburg] PHP   9. call_user_func_array:{/var/www/mysite2.su/htdocs/libraries/joomla/event/event.php:69}() /var/www/mysite2.su/htdocs/libraries/joomla/event/event.php:69
[22-Apr-2016 12:07:38 Asia/Yekaterinburg] PHP  10. PlgSystemRemember->onAfterInitialise() /var/www/mysite2.su/htdocs/libraries/joomla/event/event.php:69
[22-Apr-2016 12:07:38 Asia/Yekaterinburg] PHP  11. JUserHelper::getShortHashedUserAgent() /var/www/mysite2.su/htdocs/plugins/system/remember/remember.php:54
[22-Apr-2016 12:07:38 Asia/Yekaterinburg] PHP  12. JUri::base() /var/www/mysite2.su/htdocs/libraries/joomla/user/helper.php:810
[22-Apr-2016 12:07:38 Asia/Yekaterinburg] PHP  13. JUri::getInstance() /var/www/mysite2.su/htdocs/libraries/joomla/uri/uri.php:135
[22-Apr-2016 12:07:38 Asia/Yekaterinburg] PHP Notice:  Undefined index: HTTP_USER_AGENT in /var/www/mysite2.su/htdocs/modules/mod_djimageslider/mod_djimageslider.php on line 93
[22-Apr-2016 12:07:38 Asia/Yekaterinburg] PHP Stack trace:
[22-Apr-2016 12:07:38 Asia/Yekaterinburg] PHP   1. {main}() /var/www/mysite2.su/htdocs/index.php:0
[22-Apr-2016 12:07:38 Asia/Yekaterinburg] PHP   2. JApplicationCms->execute() /var/www/mysite2.su/htdocs/index.php:49
[22-Apr-2016 12:07:38 Asia/Yekaterinburg] PHP   3. JApplicationSite->render() /var/www/mysite2.su/htdocs/libraries/cms/application/cms.php:263
[22-Apr-2016 12:07:38 Asia/Yekaterinburg] PHP   4. JApplicationCms->render() /var/www/mysite2.su/htdocs/libraries/cms/application/site.php:745
[22-Apr-2016 12:07:38 Asia/Yekaterinburg] PHP   5. JDocumentHtml->render() /var/www/mysite2.su/htdocs/libraries/cms/application/cms.php:1068
[22-Apr-2016 12:07:38 Asia/Yekaterinburg] PHP   6. JDocumentHtml->_renderTemplate() /var/www/mysite2.su/htdocs/libraries/joomla/document/html.php:477
[22-Apr-2016 12:07:38 Asia/Yekaterinburg] PHP   7. JDocumentHtml->getBuffer() /var/www/mysite2.su/htdocs/libraries/joomla/document/html.php:697

...

[26-Apr-2016 11:37:56 Asia/Yekaterinburg] PHP   5. JComponentHelper::renderComponent() /var/www/mysite2.su/htdocs/libraries/cms/application/administrator.php:98
[26-Apr-2016 11:37:56 Asia/Yekaterinburg] PHP   6. JComponentHelper::executeComponent() /var/www/mysite2.su/htdocs/libraries/cms/component/helper.php:380
[26-Apr-2016 11:37:56 Asia/Yekaterinburg] PHP   7. require_once() /var/www/mysite2.su/htdocs/libraries/cms/component/helper.php:405
[26-Apr-2016 11:37:56 Asia/Yekaterinburg] PHP   8. ConfigControllerApplicationSave->execute() /var/www/mysite2.su/htdocs/administrator/components/com_config/config.php:31
[26-Apr-2016 11:37:56 Asia/Yekaterinburg] PHP   9. ConfigModelApplication->save() /var/www/mysite2.su/htdocs/administrator/components/com_config/controller/application/save.php:90
[26-Apr-2016 11:37:56 Asia/Yekaterinburg] PHP  10. ConfigModelApplication->writeConfigFile() /var/www/mysite2.su/htdocs/administrator/components/com_config/model/application.php:257
[26-Apr-2016 11:37:56 Asia/Yekaterinburg] PHP  11. JFile::write() /var/www/mysite2.su/htdocs/administrator/components/com_config/model/application.php:317
[26-Apr-2016 11:37:56 Asia/Yekaterinburg] PHP  12. file_put_contents() /var/www/mysite2.su/htdocs/libraries/joomla/filesystem/file.php:435
php-fpm.log показывает некоторые ошибки выкладываю по ссылке, много текста https://yadi.sk/i/nYrxwxszrUCFs (ничего умнее не придумал)

MrFakir
() автор топика
Ответ на: комментарий от Goury

На другом форуме посоветовали подумать о взломе. Заметил в логах php-fmp.log вот такое

[error] 24183#0: *59622995 connect() failed (111: Connection refused) while connecting to upstream, client: 66.249.78.129 (последние две цифры адреса «78.129"меняются), server: mysite.ru, request: „GET /medik/UserFiles/Flash/seks/porno-dvuh.html HTTP/1.1“, upstream: »http://ip моего сервера:80/medik/UserFiles/Flash/seks/porno-dvuh.html", host: «mysite.ru» Таких файлов на сервере нет, точно.

Может залочить доступ адресу 66.249.*.* есть ли такая возможность вообще? (сервер мой, доступ полный)

MrFakir
() автор топика
Ответ на: комментарий от MrFakir

Нет, надо не доступ лочить, а разбираться кто и зачем туда ходит. Включи логирование конкретного скрипта и номера строчки кода и посмотри что там в нём происходит. Ну и трассировку для таких запросов в лог тоже может стоит выводить.

К тому же на 66.249 у него явно не получается, но это не значит что нет других адресов этой дряни, на которые успех.
Лечить надо причину, а не симптомы.

Goury ★★★★★
()
Ответ на: комментарий от Goury

nginx error

2016/05/04 13:42:02 [error] 30507#0: *4155654 recv() failed (104: Connection reset by peer) while reading reing response header from upstream, client: 157.55.39.178, server: uralpress.ru, request: "GET /news/2008/09/10/kadrovyi-rezerv-sledstvennogo-komiteta-rf-popolnitsya-obshchestvennymi-pomoshchnikam HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "mysite.ru"

2016/05/04 13:42:02 [crit] 30507#0: *4155656 connect() to unix:/var/run/php5-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 95.79.46.33, server: uralpress.ru, request: "GET /news/2006/07/24/mmk-sovershenstvuet-strukturu-upravleniya HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "mysite.ru"
php-fpm
[04-May-2016 13:42:02.256904] DEBUG: pid 11218, fpm_children_make(), line 421: [pool www] child 11252 started
[04-May-2016 13:42:02.257328] DEBUG: pid 11218, fpm_children_make(), line 421: [pool www] child 11253 started
[04-May-2016 13:42:02.257346] DEBUG: pid 11218, fpm_event_loop(), line 366: 150640 bytes have been reserved in SHM
[04-May-2016 13:42:02.257352] NOTICE: pid 11218, fpm_event_loop(), line 367: ready to handle connections
[04-May-2016 13:42:03.258443] DEBUG: pid 11218, fpm_pctl_perform_idle_server_maintenance(), line 379: [pool www] currently 0 active children, 32 spare children, 32 running children. Spawning rate 1

Насколько я понимаю нужно было ошибки которые появляются в одно и то-же время. Во время 502 ошибки, nginx логирует 104: Connection... то что в это время в логах php представляю выше.

MrFakir
() автор топика
Ответ на: комментарий от Goury

Вот тут я вообще ничего не понял.

«Включи логирование конкретного скрипта и номера строчки кода» Как? Какого?

«Ну и трассировку для таких запросов в лог тоже может стоит выводить.» Просто слова известные, а смысл не понятен.

В этом месте объяснений для «нуба» не найдётся? или хотябы что гуглить.

2ip сказал про адресс IP 66.249.78.129 Хост: crawl-66-249-78-129.googlebot.com Город: Маунтин-Вью Страна: United States IP диапазон: 66.249.64.0 - 66.249.95.255 Название провайдера: Google Inc.

googlebot?!

MrFakir
() автор топика
Ответ на: комментарий от MrFakir

Надо было ERROR, а не DEBUG или NOTICE.
104: Connection reset by peer — это явно ошибка, а не нормальное поведение.
И это не упавший/свалившийся процесс, это именно возврат ошибки.

Goury ★★★★★
()
Ответ на: комментарий от MrFakir

что гуглить

php-fpm verbose error log
Я сам пыху уже очень давно не готовил, почти всё позабыл.
Наверняка у тебя получится не хуже меня найти как там включить логирование нормальное.
Надо чтобы оно выводило место возникновения ошибки в скрипте и желательно текущие значения переменных скрипта.

Google Inc

Это пока ни о чём не говорит.
Для начала стоит выяснить что и почему туда ломится.
Может это так и надо.
А может и не надо.

Goury ★★★★★
()
Ответ на: комментарий от MrFakir
[04-May-2016 13:30:01.312672] DEBUG: pid 8575, fpm_got_signal(), line 90: received SIGQUIT

А не может быть такого, что у тебя на сервере есть какой-то скрипт, который периодически рестартует php-fpm и из-за этого у тебя вылазит 502?

Prius
()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.