Quantcast
Channel: Nginx Forum - Php-fpm Mailing List - English
Viewing all 219 articles
Browse latest View live

php5-fpm timeout (including ping and status) (no replies)

$
0
0
Hello,

I've problem with my fpm in production server. The fpm keep hanging until
I restart the service. After restarting, the problem gone. But it will
return in a day or two. Keep it restarting won't be a solution.

When the problem exists, even ping-ing time out. I don't know where to start
investaging this. Could you help me on investigating? I believe the problem
in fpm because static file still being served by nginx. I'm currently also
online on freenode #php-fpm, if anyone who prefer using irc wanted to help.

My fpm version is 5.5.9+dfsg-1ubuntu4.6 running on ubuntu 14.04

Thanks,
--
dieend

Nignx / Php FPM / SSL on Prestashop => TTFB > 8secondes (no replies)

$
0
0
Hello community :)

I come to you because I don't find any solution for my problem,

I hosted on VPS with digitalocean, in Singapour (we are located in Australia). I use Prestashop software for my store.
I installed nginx, php-fpm and mysql (LEMP Stack) by myself. No cache activated yet.. (opcache, memechached...)

But I have like 8 sec for any page in prestashop to load this page (8sec only for the Time To First Byte)

My vhost config :

server {

server_name sub.domain.com;
# Normal
listen 80;
return 301 https://$server_name$request_uri;
}


# SSL
server {

listen 443 spdy;

# Error / Access log
error_log /var/log/nginx/domain.com_error.log;
access_log /var/log/nginx/domain.com_access.log;

#ssl :
include '/etc/nginx/conf.d/ssl.conf';

# Server settings :
server_name sub.domain.com;
root /home/usersys/sites/domain.com;
index index.html index.htm index.php;
proxy_buffers 16 16k;
proxy_buffer_size 32k;

# Location php :
include '/etc/nginx/conf.d/location-php.conf';

# Cache static :
include '/etc/nginx/conf.d/cache_static.conf';

# Rewrite rule presta :
include /etc/nginx/conf.d/ps_rewrite_rules.conf;
}


ssl.conf file :

ssl on;
ssl_certificate /etc/ssl/www.domain.com.crt;
ssl_certificate_key /etc/ssl/www.domain.com.key;


ssl_ciphers ECDHE-RSA-AES256-SHA384:AES256-SHA256:RC4:HIGH:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH:!AESGCM;

ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_session_cache shared:SSL:32m;
ssl_buffer_size 4k;
ssl_session_timeout 10m;

client_max_body_size 15m;
client_body_buffer_size 128k;

ssl_stapling on;
ssl_stapling_verify on;
ssl_trusted_certificate /etc/ssl/trusted.crt;
resolver 8.8.4.4 8.8.8.8 valid=300s;
resolver_timeout 10s;

ssl_prefer_server_ciphers on;
ssl_dhparam /etc/ssl/certs/dhparam.pem;

add_header Strict-Transport-Security "max-age=31536000";
add_header X-Content-Type-Options nosniff;



location-php.conf file :

location ~ \.php$ {

try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
# With php5-cgi alone:
#fastcgi_pass 127.0.0.1:9000;
# With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param HTTPS on;
fastcgi_read_timeout 300;
fastcgi_buffers 256 16k;
fastcgi_buffer_size 32k;
fastcgi_cache phpcache; # The name of the cache key-zone to use
fastcgi_cache_valid 200 30m; # What to cache: 'code 200' responses, for half an hour
fastcgi_cache_methods GET HEAD; # What to cache: only GET and HEAD requests (ot POST)
add_header X-Fastcgi-Cache $upstream_cache_status; # Allow us to see if the cache was HIT, MISS, or BYPASSED inside a browser's Inspector panel
fastcgi_cache_bypass $no_cache; # Dont pull from the cache if true
fastcgi_no_cache $no_cache; # Dont save to the cache if true


include fastcgi_params;

}

cache_static.conf :

# Expire rules for static content

# cache.appcache, your document html and data
location ~* \.(?:manifest|appcache|html?|xml|json)$ {
expires -1;
# access_log logs/static.log; # I don't usually include a static log
}

# Feed
location ~* \.(?:rss|atom)$ {
expires 1h;
add_header Cache-Control "public";
}

# Media: images, icons, video, audio, HTC
location ~* \.(?:jpg|woff|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
expires 1M;
access_log off;
add_header Cache-Control "public";
}

# CSS and Javascript
location ~* \.(?:css|js)$ {
expires 1y;
access_log off;
add_header Cache-Control "public";
}


ps_rewrite_rules.conf :

rewrite ^/api/?(.*)$ /webservice/dispatcher.php?url=$1 last;
rewrite ^/([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$1$2.jpg last;
rewrite ^/([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$1$2$3.jpg last;
rewrite ^/([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$1$2$3$4.jpg last;
rewrite ^/([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$1$2$3$4$5.jpg last;
rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6.jpg last;
rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7.jpg last;
rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8.jpg last;
rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?(-[0-9]+)?/.+\.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9.jpg last;
rewrite ^/c/([0-9]+)(-[_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$ /img/c/$1$2.jpg last;
rewrite ^/c/([a-zA-Z-]+)(-[0-9]+)?/.+\.jpg$ /img/c/$1.jpg last;
rewrite ^/([0-9]+)(-[_a-zA-Z0-9-]*)(-[0-9]+)?/.+\.jpg$ /img/c/$1$2.jpg last;
rewrite ^/order$ /index.php?controller=order last;
if (!-e $request_filename){
rewrite ^(.*)$ /index.php last;
}


Thanks a lot :)

ngnix php-fpm error centos (no replies)

$
0
0
I'm using nginx version: nginx/1.6.2. I've tried to with only sock file but this is not working.. Anyone knows correct configuration ? Notice : it was running on 1.4.


php-fpm conf :

listen = 127.0.0.1:9000
; listen = /tmp/php5-fpm.sock

listen.allowed_clients = 127.0.0.1

listen.owner = nginx
listen.group = nginx
listen.mode = 0660
ngnix www conf :

location ~ \.php$ {
root html;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_pass 127.0.0.1:9000;
#fastcgi_pass unix:/tmp/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
include mime.types;
}
Error Line :

2015/03/29 17:34:10 [error] 1320#0: *46 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 1.3.3.3, server: ***.com, request: "GET /index.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "1.1.1.1"

nginx and PHP = 502 Bad Gateway : full detail (no replies)

$
0
0
Please help.

Here is my setup.
OS: ubuntu 14.04.2 LTS
nginx : 1.6.2
php: PHP 5.6.7

I can see the web page file ok, but not the php.

I check the error log by the following command
cat /var/log/nginx/error.log

output as:
2015/04/07 11:36:32 [error] 7495#0: *1 connect() to unix:/var/run/php5-fpm.sock failed (111: Connection refused) while connecting to upstream, client: 192.168.0.252, server: _, request: "GET /info.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "192.168.0.241"

How can I fix the issue?

Sincrely,

Start error using systemd (no replies)

$
0
0
Hi,

When I do:
#systemctl start fcgi.service

it hangs without returning me to a prompt, so I have to <Ctrl-C> out of it.

Then when I do:
#systemctl status -l fcgi.service


I get this error:
systemd[1]: PID file /var/run/php-fpm.pid not readable (yet?) after start.


This is my systemd script, /etc/systemd/system/fcgi.service:

[Unit]
Description=The PHP FastCGI Process Manager
After=network.target

[Service]
Type=forking
PIDFile=/var/run/php-fpm.pid
ExecStart=/usr/sbin/php-fpm -g /var/run/php-fpm.pid -y /etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID
ExecStop=kill $MAINPID

[Install]
WantedBy=multi-user.target


And this is my php-fpm.conf:

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

; All relative paths in this configuration file are relative to PHP's install
; prefix (/usr). This prefix can be dynamically 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 argument)
; - /usr otherwise
;include=etc/fpm.d/*.conf

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

[global]
; Pid file
; Note: the default prefix is /usr/var
; Default Value: none
pid = run/php-fpm.pid

; Error log file
; If it's set to "syslog", log is sent to syslogd instead of being written
; in a local file.
; Note: the default prefix is /usr/var
; Default Value: log/php-fpm.log
error_log = log/php-fpm.log

; syslog_facility is used to specify what type of program is logging the
; message. This lets syslogd specify that messages from different facilities
; will be handled differently.
; See syslog(3) for possible values (ex daemon equiv LOG_DAEMON)
; Default Value: daemon
;syslog.facility = daemon

; syslog_ident is prepended to every message. If you have multiple FPM
; instances running on the same server, you can change the default value
; which must suit common needs.
; Default Value: php-fpm
;syslog.ident = php-fpm

; 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 = 0

; 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 = 0

; The maximum number of processes FPM will fork. This has been design to control
; the global number of processes when using dynamic PM within a lot of pools.
; Use it with caution.
; Note: A value of 0 indicates no limit
; Default Value: 0
; process.max = 128

; Specify the nice(2) priority to apply to the master process (only if set)
; The value can vary from -19 (highest priority) to 20 (lower priority)
; Note: - It will only work if the FPM master process is launched as root
; - The pool process will inherit the master process priority
; unless it specified otherwise
; Default Value: no set
; process.priority = -19

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

; Set open file descriptor rlimit for the master process.
; Default Value: system defined value
;rlimit_files = 1024

; Set max core size rlimit for the master process.
; Possible Values: 'unlimited' or an integer greater or equal to 0
; Default Value: system defined value
;rlimit_core = 0

; Specify the event mechanism FPM will use. The following is available:
; - select (any POSIX os)
; - poll (any POSIX os)
; - epoll (linux >= 2.5.44)
; - kqueue (FreeBSD >= 4.1, OpenBSD >= 2.9, NetBSD >= 2.0)
; - /dev/poll (Solaris >= 7)
; - port (Solaris >= 10)
; Default Value: not set (auto detection)
;events.mechanism = epoll

; When FPM is build with systemd integration, specify the interval,
; in second, between health report notification to systemd.
; Set to 0 to disable.
; Available Units: s(econds), m(inutes), h(ours)
; Default Unit: seconds
; Default value: 10
;systemd_interval = 10

;;;;;;;;;;;;;;;;;;;;
; 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:
; - 'access.log'
; - 'slowlog'
; - 'listen' (unixsocket)
; - 'chroot'
; - 'chdir'
; - 'php_values'
; - 'php_admin_values'
; When not set, the global prefix (or /usr) applies instead.
; Note: This directive can also be relative to the global prefix.
; Default Value: none
;prefix = /path/to/pools/$pool

; 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 = nginx
group = nginx

; 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 IPv4 address on
; a specific port;
; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
; a specific port;
; 'port' - to listen on a TCP socket to all IPv4 addresses on a
; specific port;
; '[::]:port' - to listen on a TCP socket to all addresses
; (IPv6 and IPv4-mapped) on a specific port;
; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = 127.0.0.1:8999

; Set listen(2) backlog.
; Default Value: 65535 (-1 on FreeBSD and OpenBSD)
;listen.backlog = 65535

; 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 0660
listen.owner = nginx
listen.group = nginx
listen.mode = 0660
; When POSIX Access Control Lists are supported you can set them using
; these options, value is a comma separated list of user/group names.
; When set, listen.owner and listen.group are ignored
;listen.acl_users = nginx
;listen.acl_groups = nginx

; List of addresses (IPv4/IPv6) 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

; Specify the nice(2) priority to apply to the pool processes (only if set)
; The value can vary from -19 (highest priority) to 20 (lower priority)
; Note: - It will only work if the FPM master process is launched as root
; - The pool processes will inherit the master process priority
; unless it specified otherwise
; Default Value: no set
; process.priority = -19

; 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. With this process management, there will be
; always at least 1 children.
; 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.
; ondemand - no children are created at startup. Children will be forked when
; new requests will connect. The following parameter are used:
; pm.max_children - the maximum number of children that
; can be alive at the same time.
; pm.process_idle_timeout - The number of seconds after which
; an idle process will be killed.
; Note: This value is mandatory.
pm = dynamic

; The number of child processes to be created when pm is set to 'static' and the
; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
; 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. The below defaults are based on a server without much resources. Don't
; forget to tweak pm.* to fit your needs.
; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
; Note: This value is mandatory.
pm.max_children = 5

; 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 = 2

; 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 = 1

; 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 = 3

; The number of seconds after which an idle process will be killed.
; Note: Used only when pm is set to 'ondemand'
; Default Value: 10s
;pm.process_idle_timeout = 10s;

; 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. It shows the following informations:
; pool - the name of the pool;
; process manager - static, dynamic or ondemand;
; start time - the date and time FPM has started;
; start since - number of seconds since FPM has started;
; accepted conn - the number of request accepted by the pool;
; listen queue - the number of request in the queue of pending
; connections (see backlog in listen(2));
; max listen queue - the maximum number of requests in the queue
; of pending connections since FPM has started;
; listen queue len - the size of the socket queue of pending connections;
; idle processes - the number of idle processes;
; active processes - the number of active processes;
; total processes - the number of idle + active processes;
; max active processes - the maximum number of active processes since FPM
; has started;
; max children reached - number of times, the process limit has been reached,
; when pm tries to start more children (works only for
; pm 'dynamic' and 'ondemand');
; Value are updated in real time.
; Example output:
; pool: www
; process manager: static
; start time: 01/Jul/2011:17:53:49 +0200
; start since: 62636
; accepted conn: 190460
; listen queue: 0
; max listen queue: 1
; listen queue len: 42
; idle processes: 4
; active processes: 11
; total processes: 15
; max active processes: 12
; max children reached: 0
;
; By default the status page output is formatted as text/plain. Passing either
; 'html', 'xml' or 'json' in the 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
; http://www.foo.bar/status?xml
;
; By default the status page only outputs short status. Passing 'full' in the
; query string will also return status for each pool process.
; Example:
; http://www.foo.bar/status?full
; http://www.foo.bar/status?json&full
; http://www.foo.bar/status?html&full
; http://www.foo.bar/status?xml&full
; The Full status returns for each process:
; pid - the PID of the process;
; state - the state of the process (Idle, Running, ...);
; start time - the date and time the process has started;
; start since - the number of seconds since the process has started;
; requests - the number of requests the process has served;
; request duration - the duration in µs of the requests;
; request method - the request method (GET, POST, ...);
; request URI - the request URI with the query string;
; content length - the content length of the request (only with POST);
; user - the user (PHP_AUTH_USER) (or '-' if not set);
; script - the main script called (or '-' if not set);
; last request cpu - the %cpu the last request consumed
; it's always 0 if the process is not in Idle state
; because CPU calculation is done when the request
; processing has terminated;
; last request memory - the max amount of memory the last request consumed
; it's always 0 if the process is not in Idle state
; because memory calculation is done when the request
; processing has terminated;
; If the process is in Idle state, then informations are related to the
; last request the process has served. Otherwise informations are related to
; the current request being served.
; Example output:
; ************************
; pid: 31330
; state: Running
; start time: 01/Jul/2011:17:53:49 +0200
; start since: 63087
; requests: 12808
; request duration: 1250261
; request method: GET
; request URI: /test_mem.php?N=10000
; content length: 0
; user: -
; script: /home/fat/web/docs/php/test_mem.php
; last request cpu: 0.00
; last request memory: 0
;
; Note: There is a real-time FPM status monitoring sample web page available
; It's available in: /usr/share/php/fpm/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 = /status

; 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

; 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 access log file
; Default: not set
;access.log = log/$pool.access.log

; The access log format.
; The following syntax is allowed
; %%: the '%' character
; %C: %CPU used by the request
; it can accept the following format:
; - %{user}C for user CPU only
; - %{system}C for system CPU only
; - %{total}C for user + system CPU (default)
; %d: time taken to serve the request
; it can accept the following format:
; - %{seconds}d (default)
; - %{miliseconds}d
; - %{mili}d
; - %{microseconds}d
; - %{micro}d
; %e: an environment variable (same as $_ENV or $_SERVER)
; it must be associated with embraces to specify the name of the env
; variable. Some exemples:
; - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e
; - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e
; %f: script filename
; %l: content-length of the request (for POST request only)
; %m: request method
; %M: peak of memory allocated by PHP
; it can accept the following format:
; - %{bytes}M (default)
; - %{kilobytes}M
; - %{kilo}M
; - %{megabytes}M
; - %{mega}M
; %n: pool name
; %o: output header
; it must be associated with embraces to specify the name of the header:
; - %{Content-Type}o
; - %{X-Powered-By}o
; - %{Transfert-Encoding}o
; - ....
; %p: PID of the child that serviced the request
; %P: PID of the parent of the child that serviced the request
; %q: the query string
; %Q: the '?' character if query string exists
; %r: the request URI (without the query string, see %q and %Q)
; %R: remote IP address
; %s: status (response code)
; %t: server time the request was received
; it can accept a strftime(3) format:
; %d/%b/%Y:%H:%M:%S %z (default)
; %T: time the log has been written (the request has finished)
; it can accept a strftime(3) format:
; %d/%b/%Y:%H:%M:%S %z (default)
; %u: remote user
;
; Default: "%R - %u %t \"%m %r\" %s"
;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%"

; The log file for slow requests
; Default Value: not set
; Note: slowlog is mandatory if request_slowlog_timeout is set
;slowlog = log/$pool.log.slow

; 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 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

; Set open file descriptor rlimit.
; Default Value: system defined value
;rlimit_files = 1024

; 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

; Clear environment in FPM workers
; Prevents arbitrary environment variables from reaching FPM worker processes
; by clearing the environment in workers before env vars specified in this
; pool configuration are added.
; Setting to "no" will make all environment variables available to PHP code
; via getenv(), $_ENV and $_SERVER.
; Default Value: yes
;clear_env = no

; Limits the extensions of the main script FPM will allow to parse. This can
; prevent configuration mistakes on the web server side. You should only limit
; FPM to .php extensions to prevent malicious users to use other extensions to
; exectute php code.
; Note: set an empty value to allow all extensions.
; Default Value: .php
;security.limit_extensions = .php .php3 .php4 .php5

; 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)

; 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] = off
;php_admin_value[error_log] = /var/log/fpm-php.www.log
;php_admin_flag[log_errors] = on
;php_admin_value[memory_limit] = 32M



What do I have to do to get it to start properly?

Thanks in advance.

502 error due to PHP crashes with signal 6 (SIGABRT) or 11 (SIGSEGV) (1 reply)

$
0
0
I've seen a lot of posts that others get 502 error due to PHP crashes with signal 6 (SIGABRT) or 11 (SIGSEGV) but unfortunately none of the provided solution fixes mine. I'm in the process to get the back trace of the core dump but in the meantime, I just want to post here to see if any of you have any hint or procedure to debug this.

Here's what happen: various scripts crash at kind of random places but most of time *after* the main script exits/returns (with no error), i.e., the class destructor/shutdown methods get called and the last line in the main script gets executed.

I've tried all the settings combination so I won't post them here but I'll post if whatever you need to know.
Nginx => 1.6.2
PHP Version => 5.3.19
libcouchbase version => 2.5.0
memcached Version => 2.1.0
MySQL Client API version => 5.5.28

-Frank

P.S. I'll post these questions in separate topics:
1) What exactly happen after the script exits/returns (besides saving the session)?
What does php-fpm do to the process when it gets returned to the pool? (e.g. class states, static variables, database connections? I assume they all garbage collected)

php-fpm environment variables on starup (1 reply)

$
0
0
Hello,

I really want to use php-fpm (thinking ahead for high request volume) but I need to load a DB driver that needs some environment variables to be loaded on startup.

Does anybody have any details on how to do it?

I tried updating: the pool config file with:

env[XXX] = 'YYY'

but if in the driver I do a "getenv(XXX)" the environment variable is not there.

If I run "php-fpm -i" from the command line I can see that the env variable is passed to to my driver correctly.

For Reference I run:

CentOS 7 with php 5.4.16(the version that comes with CentOS 7) any clues in the right direction are appreciated

Thank you.

nginx error coming in some modules (no replies)

$
0
0
Hi

nginx error!
The page you are looking for is temporarily unavailable. Please try again later.
This error coming only some modules,Please help

Can't resolve: nginx + php-fpm + fpm-status = 404 error :( (no replies)

$
0
0
Can't resolve: nginx + php-fpm + fpm-status = 404 error :(


Hi,

I'm in the process of setting up & configuring nginx on my Raspberry Pi running Raspbian/Debian "Jessie". Issue at hand is, that even after scouting The Net, trying out various hints, starting from scratch, using perusio's brilliant work as the foundation, I'm still failing pretty badly at even getting the very basics in terms of php working properly. :(

*Software*
+----------------------------------------------------------------------+
:: linux armv7l 4.0.9-v7+ (debian "Jessie")
:: nginx 1.9.4
:: php/php-fpm 5.6.9
:: mysql 5.5.44
+----------------------------------------------------------------------+

*php-fpm (pool) configuration*
+----------------------------------------------------------------------+
[www]
user = www
group = www
listen = /var/run/php-fpm/www.php5-fpm.sock
listen.owner = www
listen.group = www
pm = dynamic
pm.max_children = 50
pm.start_servers = 3
pm.min_spare_servers = 3
pm.max_spare_servers = 10
pm.status_path = /phpfpm-status
ping.path = /phpfpm-ping
ping.response = phpfpm-pong
access.log = /var/log/php-fpm/$pool.access.log
slowlog = /var/log/php-fpm/$pool.log.slow
+----------------------------------------------------------------------+

*nginx configuration*

**nginx.conf**
+----------------------------------------------------------------------+
user www www;
error_log /var/log/nginx/error.log;
pid /var/run/nginx/nginx.pid;
worker_rlimit_nofile 1024;

events {
worker_connections 512;
multi_accept on;
} # evnets

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

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

sendfile on;
set_real_ip_from 0.0.0.0/32; # all addresses get a real IP.
real_ip_header X-Forwarded-For; # the ip is forwarded from the load balancer/proxy

limit_conn_zone $binary_remote_addr zone=arbeit:10m;

client_body_timeout 60;
client_header_timeout 60;
keepalive_timeout 10 10;
send_timeout 60;

reset_timedout_connection on;

client_max_body_size 10m;

tcp_nodelay on;
tcp_nopush on;

gzip on;
gzip_buffers 16 8k;
gzip_comp_level 1;
gzip_http_version 1.1;
gzip_min_length 10;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/x-icon application/vnd.ms-fontobject font/opentype application/x-font-ttf;
gzip_vary on;
gzip_proxied any; # Compression for all requests.
gzip_disable msie6;

server_tokens off;

ssl_session_cache shared:SSL:30m;
ssl_session_timeout 1d;
ssl_prefer_server_ciphers on;
ssl_ciphers ECDH+aRSA+AESGCM:ECDH+aRSA+SHA384:ECDH+aRSA+SHA256:ECDH:EDH+CAMELLIA:EDH+aRSA:+CAMELLIA256:+AES256:+CAMELLIA128:+AES128:+SSLv3:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS:!RC4:!SEED:!ECDSA:CAMELLIA256-SHA:AES256-SHA:CAMELLIA128-SHA:AES128-SHA;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_dhparam /etc/nginx/dh_param.pem;
ssl_ecdh_curve secp521r1;
ssl_stapling on;
ssl_stapling_verify on;

resolver 192.168.5.81;

upload_progress uploads 1m;

add_header X-XSS-Protection '1; mode=block';
add_header X-Frame-Options DENY;
add_header X-Content-Options nosniff;
add_header X-Micro-Cache $upstream_cache_status;

include conf.d/fastcgi.conf;
include conf.d/upstream_phpcgi_unix.conf;
include conf.d/map_block_http_methods.conf;

map $http_x_forwarded_proto $fastcgi_https {
default $https;
http '';
https on;
}

include conf.d/php_fpm_status_allowed_hosts.conf;
include conf.d/nginx_status_allowed_hosts.conf;
include conf.d/blacklist.conf;
include apps.d/drupal/map_cache.conf;
include conf.d/fastcgi_microcache_zone.conf;

include sites-enabled/*;
} # http
+----------------------------------------------------------------------+

**my.host.local.conf**
+----------------------------------------------------------------------+
server {
listen 192.168.5.50:80; # IPv4
return 301 $scheme://my.host.local$request_uri;
} # server domain return.

server {
server_name my.host.local;
listen 192.168.5.50:80;
limit_conn arbeit 32;

access_log /var/log/nginx/my.host.local-access.log;
error_log /var/log/nginx/my.host.local-error.log debug;

root /data/www/sites/my.host.local/htdocs;
index index.html index.htm index.nginx.html index.nginx-debian.html index.php;

if ($bad_bot) {
return 444;
} # bad_bot
if ($bad_referer) {
return 444;
} # bad_referer
if ($not_allowed_method) {
return 405;
} # not_allowed_method
location ~ /\.ht {
deny all;
}

# location ~ \.php$ {
# include snippets/fastcgi-php.conf;
# include snippets/fastcgi_pass.conf;
# }
fastcgi_keep_conn on; # keep alive to the FCGI upstream

location /drupal {
alias /data/www/sites/my.host.local/apps/drupal;
}

location /phpmyadm {
alias /data/www/sites/my.host.local/apps/phpmyadmin;
}

location /piwik {
alias /data/www/sites/my.host.local/apps/piwik;
}

location /suitecrm {
alias /data/www/sites/my.host.local/apps/suitecrm;
}

location /sugarcrm {
alias /data/www/sites/my.host.local/apps/sugarcrm;
}

location /tools {
alias /data/www/sites/my.host.local/tools;
}

#include apps.d/drupal/drupal-drupal.conf;
#include apps.d/drupal/drupal-drupal8.conf;
#include apps.d/phpmyadmin/phpmyadmin.conf;
#include apps.d/suitecrm/suitecrm.conf;
#include apps.d/sugarcrm/sugarcrm.conf;

include conf.d/php_fpm_status_vhost.conf;
include conf.d/nginx_status_vhost.conf;
include conf.d/phpinfo.conf;

# location / {
# try_files $uri $uri/ =404;
# }
} # HTTP server
+----------------------------------------------------------------------+

**conf.d/fastcgi.conf**
+----------------------------------------------------------------------+
include conf.d/fastcgi_params;
fastcgi_buffers 256 4k;
fastcgi_intercept_errors on;
fastcgi_read_timeout 14400;
fastcgi_index index.php;
fastcgi_hide_header 'X-Drupal-Cache';
fastcgi_hide_header 'X-Generator';
+----------------------------------------------------------------------+

**conf.d/fastcgi.conf**
+----------------------------------------------------------------------+
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_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;

fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;

fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

fastcgi_param REDIRECT_STATUS 200;
fastcgi_param HTTPS $fastcgi_https if_not_empty;
+----------------------------------------------------------------------+

**conf.d/upstream_phpcgi_unix.conf**
+----------------------------------------------------------------------+
upstream phpcgi {
least_conn;
server unix:/var/run/php-fpm/www.php5-fpm.sock;
keepalive 5;
}
upstream www {
server unix:/var/run/php-fpm/www.php5-fpm.sock;
}
+----------------------------------------------------------------------+

**conf.d/php_fpm_status_allowed_hosts.conf**
+----------------------------------------------------------------------+
geo $dont_show_fpm_status {
default 1;
127.0.0.1 0;
192.168.0.0/16 0;
}
+----------------------------------------------------------------------+

**conf.d/blacklist.conf**
+----------------------------------------------------------------------+
map $http_user_agent $bad_bot {
default 0;
~*^Lynx 0; # Let Lynx go through
libwww-perl 1;
~(?i)(httrack|htmlparser|libwww) 1;
}

map $http_referer $bad_referer {
default 0;
~(?i)(adult|babes|click|diamond|forsale|girl|jewelry|love|nudit|organic|poker|porn|poweroversoftware|sex|teen|webcam|zippo|casino|replica) 1;
}

geo $bad_referer {
127.0.0.1 0;
192.168.0.0/16 0;
}
+----------------------------------------------------------------------+

**apps.d/drupal/map_cache.conf**
+----------------------------------------------------------------------+
map $uri $no_cache_ajax {
default 0;
/system/ajax 1;
/drupal/system/ajax 1;
/drupal8/system/ajax 1;
}
map $http_cookie $no_cache_cookie {
default 0;
~SESS 1; # PHP session cookie
}
map $no_cache_ajax$no_cache_cookie $no_cache {
default 1;
00 0;
}
map $http_cookie $cache_uid {
default nil; # hommage to Lisp :)
~SESS[[:alnum:]]+=(?<session_id>[[:graph:]]+) $session_id;
}
+----------------------------------------------------------------------+

**conf.d/fastcgi_microcache_zone.conf**
+----------------------------------------------------------------------+
fastcgi_cache_path /var/cache/nginx/microcache levels=1:2 keys_zone=microcache:5M max_size=1G inactive=2h loader_threshold=2000000 loader_sleep=1 loader_files=100000;
+----------------------------------------------------------------------+

**conf.d/php_fpm_status_vhost.conf**
+----------------------------------------------------------------------+
location = /phpfpm-status {
if ($dont_show_fpm_status) {
return 404;
}
include snippets/fastcgi-php.conf;
include snippets/fastcgi_pass.conf;
access_log off;
}

location = /phpfpm-ping {
if ($dont_show_fpm_status) {
return 404;
}
include snippets/fastcgi-php.conf;
include snippets/fastcgi_pass.conf;
access_log off;
}
+----------------------------------------------------------------------+

**snippets/fastcgi-php.conf**
+----------------------------------------------------------------------+
fastcgi_split_path_info ^(.+\.php)(/.+)$;

try_files $fastcgi_script_name =404;

set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;

fastcgi_index index.php;
+----------------------------------------------------------------------+

**snippets/fastcgi_pass.conf**
+----------------------------------------------------------------------+
#fastcgi_pass unix:/var/run/php-fpm/www.php5-fpm.sock;
fastcgi_pass phpcgi;
#fastcgi_pass www;
+----------------------------------------------------------------------+

Checking the configuration file results in a "Syntax Ok" message, nginx can get launched and html files are served like a charm, even the nginx status page can be pulled.

Looking into the error/debug file reveals
+----------------------------------------------------------------------+
2015/08/26 11:13:39 [debug] 32689#32689: *2 http header: "Host: my.host.local"
2015/08/26 11:13:39 [debug] 32689#32689: *2 http header: "Cache-Control: max-age=0"
2015/08/26 11:13:39 [debug] 32689#32689: *2 http header: "Cookie: ck_login_id_20=1; ck_login_language_20=en_us; _pk_id.1.9807=7f9462efb2565826.1440510573.1.1440577057.1440510573.; _pk_ses.1.9807=*; PHPSESSID=6frcrj852ns5hmtpum3me8o6m1; PIWIK_SESSID=c6olsns21t9pgngalch0jak950; TRACKID=feb76f8fcaa01cb61cc137ec587c96b1"
2015/08/26 11:13:39 [debug] 32689#32689: *2 http header: "Connection: keep-alive"
2015/08/26 11:13:39 [debug] 32689#32689: *2 http header: "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
2015/08/26 11:13:39 [debug] 32689#32689: *2 http header: "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11) AppleWebKit/601.1.43 (KHTML, like Gecko) Version/9.0 Safari/601.1.43"
2015/08/26 11:13:39 [debug] 32689#32689: *2 http header: "Accept-Language: en-us"
2015/08/26 11:13:39 [debug] 32689#32689: *2 http header: "Accept-Encoding: gzip, deflate"
2015/08/26 11:13:39 [debug] 32689#32689: *2 http header: "DNT: 1"
2015/08/26 11:13:39 [debug] 32689#32689: *2 http header done
2015/08/26 11:13:39 [debug] 32689#32689: *2 event timer del: 18: 1766434846
2015/08/26 11:13:39 [debug] 32689#32689: *2 generic phase: 0
2015/08/26 11:13:39 [debug] 32689#32689: *2 rewrite phase: 1
2015/08/26 11:13:39 [debug] 32689#32689: *2 http script var
2015/08/26 11:13:39 [debug] 32689#32689: *2 http map started
2015/08/26 11:13:39 [debug] 32689#32689: *2 http script var: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11) AppleWebKit/601.1.43 (KHTML, like Gecko) Version/9.0 Safari/601.1.43"
2015/08/26 11:13:39 [debug] 32689#32689: *2 http map: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11) AppleWebKit/601.1.43 (KHTML, like Gecko) Version/9.0 Safari/601.1.43" "0"
2015/08/26 11:13:39 [debug] 32689#32689: *2 http script var: "0"
2015/08/26 11:13:39 [debug] 32689#32689: *2 http script if
2015/08/26 11:13:39 [debug] 32689#32689: *2 http script if: false
2015/08/26 11:13:39 [debug] 32689#32689: *2 http script var
2015/08/26 11:13:39 [debug] 32689#32689: *2 http geo started: 192.168.5.100
2015/08/26 11:13:39 [debug] 32689#32689: *2 http geo: 0
2015/08/26 11:13:39 [debug] 32689#32689: *2 http script var: "0"
2015/08/26 11:13:39 [debug] 32689#32689: *2 http script if
2015/08/26 11:13:39 [debug] 32689#32689: *2 http script if: false
2015/08/26 11:13:39 [debug] 32689#32689: *2 http script var
2015/08/26 11:13:39 [debug] 32689#32689: *2 http map started
2015/08/26 11:13:39 [debug] 32689#32689: *2 http script var: "GET"
2015/08/26 11:13:39 [debug] 32689#32689: *2 http map: "GET" "0"
2015/08/26 11:13:39 [debug] 32689#32689: *2 http script var: "0"
2015/08/26 11:13:39 [debug] 32689#32689: *2 http script if
2015/08/26 11:13:39 [debug] 32689#32689: *2 http script if: false
2015/08/26 11:13:39 [debug] 32689#32689: *2 test location: "/phpmyadm"
2015/08/26 11:13:39 [debug] 32689#32689: *2 test location: "/phpfpm-ping"
2015/08/26 11:13:39 [debug] 32689#32689: *2 test location: "/phpinfo"
2015/08/26 11:13:39 [debug] 32689#32689: *2 test location: "/phpfpm-status"
2015/08/26 11:13:39 [debug] 32689#32689: *2 using configuration "=/phpfpm-status"
2015/08/26 11:13:39 [debug] 32689#32689: *2 http cl:-1 max:10485760
2015/08/26 11:13:39 [debug] 32689#32689: *2 rewrite phase: 3
2015/08/26 11:13:39 [debug] 32689#32689: *2 rewrite phase: 4
2015/08/26 11:13:39 [debug] 32689#32689: *2 http script var
2015/08/26 11:13:39 [debug] 32689#32689: *2 http geo started: 192.168.5.100
2015/08/26 11:13:39 [debug] 32689#32689: *2 http geo: 0
2015/08/26 11:13:39 [debug] 32689#32689: *2 http script var: "0"
2015/08/26 11:13:39 [debug] 32689#32689: *2 http script if
2015/08/26 11:13:39 [debug] 32689#32689: *2 http script if: false
2015/08/26 11:13:39 [debug] 32689#32689: *2 http script complex value
2015/08/26 11:13:39 [debug] 32689#32689: *2 http script var: ""
2015/08/26 11:13:39 [debug] 32689#32689: *2 http script set $path_info
2015/08/26 11:13:39 [debug] 32689#32689: *2 post rewrite phase: 5
2015/08/26 11:13:39 [debug] 32689#32689: *2 generic phase: 6
2015/08/26 11:13:39 [debug] 32689#32689: *2 generic phase: 7
2015/08/26 11:13:39 [debug] 32689#32689: *2 generic phase: 8
2015/08/26 11:13:39 [debug] 32689#32689: *2 generic phase: 9
2015/08/26 11:13:39 [debug] 32689#32689: *2 http script var: "¿®?d"
2015/08/26 11:13:39 [debug] 32689#32689: *2 limit conn: B7CA6CC6 1
2015/08/26 11:13:39 [debug] 32689#32689: *2 add cleanup: 012E4E20
2015/08/26 11:13:39 [debug] 32689#32689: *2 access phase: 10
2015/08/26 11:13:39 [debug] 32689#32689: *2 access phase: 11
2015/08/26 11:13:39 [debug] 32689#32689: *2 access phase: 12
2015/08/26 11:13:39 [debug] 32689#32689: *2 post access phase: 13
2015/08/26 11:13:39 [debug] 32689#32689: *2 try files phase: 14
2015/08/26 11:13:39 [debug] 32689#32689: *2 http script var: "/phpfpm-status"
2015/08/26 11:13:39 [debug] 32689#32689: *2 trying to use file: "/phpfpm-status" "/data/www/sites/my.host.local/htdocs/phpfpm-status"
2015/08/26 11:13:39 [debug] 32689#32689: *2 trying to use file: "=404" "/data/www/sites/my.host.local/htdocs=404"
2015/08/26 11:13:39 [debug] 32689#32689: *2 http finalize request: 404, "/phpfpm-status?" a:1, c:1
2015/08/26 11:13:39 [debug] 32689#32689: *2 http special response: 404, "/phpfpm-status?"
2015/08/26 11:13:39 [debug] 32689#32689: *2 http set discard body
2015/08/26 11:13:39 [debug] 32689#32689: *2 uploadprogress error-tracker error: 404
2015/08/26 11:13:39 [debug] 32689#32689: *2 uploadprogress error-tracker not tracking in this location
2015/08/26 11:13:39 [debug] 32689#32689: *2 xslt filter header
2015/08/26 11:13:39 [debug] 32689#32689: *2 HTTP/1.1 404 Not Found

Server: nginx

Date: Wed, 26 Aug 2015 09:13:39 GMT

Content-Type: text/html

Transfer-Encoding: chunked

Connection: keep-alive

Keep-Alive: timeout=10

Vary: Accept-Encoding

Content-Encoding: gzip


2015/08/26 11:13:39 [debug] 32689#32689: *2 write new buf t:1 f:0 012E4F70, pos 012E4F70, size: 226 file: 0, size: 0
2015/08/26 11:13:39 [debug] 32689#32689: *2 http write filter: l:0 f:0 s:226
2015/08/26 11:13:39 [debug] 32689#32689: *2 http output filter "/phpfpm-status?"
2015/08/26 11:13:39 [debug] 32689#32689: *2 http copy filter: "/phpfpm-status?"
2015/08/26 11:13:39 [debug] 32689#32689: *2 image filter
2015/08/26 11:13:39 [debug] 32689#32689: *2 xslt filter body
2015/08/26 11:13:39 [debug] 32689#32689: *2 http postpone filter "/phpfpm-status?" 012E5140
2015/08/26 11:13:39 [debug] 32689#32689: *2 http gzip filter
2015/08/26 11:13:39 [debug] 32689#32689: *2 malloc: 0127D7D0:12288
2015/08/26 11:13:39 [debug] 32689#32689: *2 gzip alloc: n:1 s:5828 a:8192 p:0127D7D0
2015/08/26 11:13:39 [debug] 32689#32689: *2 gzip alloc: n:512 s:2 a:1024 p:0127F7D0
2015/08/26 11:13:39 [debug] 32689#32689: *2 gzip alloc: n:512 s:2 a:1024 p:0127FBD0
2015/08/26 11:13:39 [debug] 32689#32689: *2 gzip alloc: n:512 s:2 a:1024 p:0127FFD0
2015/08/26 11:13:39 [debug] 32689#32689: *2 gzip alloc: n:256 s:4 a:1024 p:012803D0
2015/08/26 11:13:39 [debug] 32689#32689: *2 gzip in: 012E5170
2015/08/26 11:13:39 [debug] 32689#32689: *2 gzip in_buf:012E5070 ni:0014AE1C ai:116
2015/08/26 11:13:39 [debug] 32689#32689: *2 malloc: 012807D8:8192
2015/08/26 11:13:39 [debug] 32689#32689: *2 deflate in: ni:0014AE1C no:012807D8 ai:116 ao:8192 fl:0 redo:0
2015/08/26 11:13:39 [debug] 32689#32689: *2 deflate out: ni:0014AE90 no:012807D8 ai:0 ao:8192 rc:0
2015/08/26 11:13:39 [debug] 32689#32689: *2 gzip in_buf:012E5070 pos:0014AE1C
2015/08/26 11:13:39 [debug] 32689#32689: *2 gzip in: 012E5180
2015/08/26 11:13:39 [debug] 32689#32689: *2 gzip in_buf:012E50B0 ni:0014A028 ai:46
2015/08/26 11:13:39 [debug] 32689#32689: *2 deflate in: ni:0014A028 no:012807D8 ai:46 ao:8192 fl:4 redo:0
2015/08/26 11:13:39 [debug] 32689#32689: *2 deflate out: ni:0014A056 no:01280843 ai:0 ao:8085 rc:1
2015/08/26 11:13:39 [debug] 32689#32689: *2 gzip in_buf:012E50B0 pos:0014A028
2015/08/26 11:13:39 [debug] 32689#32689: *2 free: 0127D7D0
2015/08/26 11:13:39 [debug] 32689#32689: *2 posix_memalign: 0127D7D0:4096 @16
2015/08/26 11:13:39 [debug] 32689#32689: *2 http chunk: 10
2015/08/26 11:13:39 [debug] 32689#32689: *2 http chunk: 115
2015/08/26 11:13:39 [debug] 32689#32689: *2 write old buf t:1 f:0 012E4F70, pos 012E4F70, size: 226 file: 0, size: 0
2015/08/26 11:13:39 [debug] 32689#32689: *2 write new buf t:1 f:0 0127D860, pos 0127D860, size: 4 file: 0, size: 0
2015/08/26 11:13:39 [debug] 32689#32689: *2 write new buf t:0 f:0 00000000, pos 0014CB30, size: 10 file: 0, size: 0
2015/08/26 11:13:39 [debug] 32689#32689: *2 write new buf t:1 f:0 012807D8, pos 012807D8, size: 115 file: 0, size: 0
2015/08/26 11:13:39 [debug] 32689#32689: *2 write new buf t:0 f:0 00000000, pos 00124A88, size: 7 file: 0, size: 0
2015/08/26 11:13:39 [debug] 32689#32689: *2 http write filter: l:1 f:1 s:362
2015/08/26 11:13:39 [debug] 32689#32689: *2 http write filter limit 0
2015/08/26 11:13:39 [debug] 32689#32689: *2 writev: 362 of 362
2015/08/26 11:13:39 [debug] 32689#32689: *2 http write filter 00000000
2015/08/26 11:13:39 [debug] 32689#32689: *2 http copy filter: 0 "/phpfpm-status?"
2015/08/26 11:13:39 [debug] 32689#32689: *2 http finalize request: 0, "/phpfpm-status?" a:1, c:1
2015/08/26 11:13:39 [debug] 32689#32689: *2 set http keepalive handler
2015/08/26 11:13:39 [debug] 32689#32689: *2 http close request
2015/08/26 11:13:39 [debug] 32689#32689: *2 http log handler
2015/08/26 11:13:39 [debug] 32689#32689: *2 run cleanup: 012E4E20
2015/08/26 11:13:39 [debug] 32689#32689: *2 free: 012807D8
2015/08/26 11:13:39 [debug] 32689#32689: *2 free: 00000000
2015/08/26 11:13:39 [debug] 32689#32689: *2 free: 012E4230, unused: 8
2015/08/26 11:13:39 [debug] 32689#32689: *2 free: 0127D7D0, unused: 3784
2015/08/26 11:13:39 [debug] 32689#32689: *2 free: 0136A3B0
2015/08/26 11:13:39 [debug] 32689#32689: *2 hc free: 00000000 0
2015/08/26 11:13:39 [debug] 32689#32689: *2 hc busy: 00000000 0
2015/08/26 11:13:39 [debug] 32689#32689: *2 tcp_nodelay
2015/08/26 11:13:39 [debug] 32689#32689: *2 reusable connection: 1
2015/08/26 11:13:39 [debug] 32689#32689: *2 event timer add: 18: 10000:1766384847
2015/08/26 11:13:39 [debug] 32689#32689: *2 post event 0137ECE8
2015/08/26 11:13:39 [debug] 32689#32689: *2 delete posted event 0137ECE8
2015/08/26 11:13:39 [debug] 32689#32689: *2 http keepalive handler
2015/08/26 11:13:39 [debug] 32689#32689: *2 malloc: 0136A3B0:1024
2015/08/26 11:13:39 [debug] 32689#32689: *2 recv: fd:18 -1 of 1024
2015/08/26 11:13:39 [debug] 32689#32689: *2 recv() not ready (11: Resource temporarily unavailable)
2015/08/26 11:13:39 [debug] 32689#32689: *2 free: 0136A3B0
2015/08/26 11:13:49 [debug] 32689#32689: *2 event timer del: 18: 1766384847
2015/08/26 11:13:49 [debug] 32689#32689: *2 http keepalive handler
2015/08/26 11:13:49 [debug] 32689#32689: *2 close http connection: 18
2015/08/26 11:13:49 [debug] 32689#32689: *2 reusable connection: 0
2015/08/26 11:13:49 [debug] 32689#32689: *2 free: 00000000
2015/08/26 11:13:49 [debug] 32689#32689: *2 free: 01278F30, unused: 8
2015/08/26 11:13:49 [debug] 32689#32689: *2 free: 01279050, unused: 232
+----------------------------------------------------------------------+

Any hints as how to tackle this one would be highly appreciated! :)

How to prevent Nginx from capturing errors from FastCGI/PHP-FPM? (no replies)

$
0
0
I'm using Nginx 1.8.1 as a reverse proxy in front of PHP 5.6.20 over FastCGI (PHP-FPM), and I'm finding that all the notice/warning/error logs from PHP are also being logged in Nginx as errors. Is there any way to prevent such logs from propagating to Nginx' logs? I want them logged in PHP's log file only.

Here's an example:

[29-Apr-2016 22:23:10] WARNING: [pool www] child 20 said into stderr: "NOTICE: PHP message: PHP Warning: phpinfo(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /opt/web-app/index.php on line 2"

That same log is them added to Nginx' log file as an error:

2016/04/29 22:23:10 [error] 6#0: 1 FastCGI sent in stderr: "PHP message: PHP Warning: phpinfo(): It is not safe to rely on the system's timezone settings. You are *required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /opt/web-app/index.php on line 2" while reading response header from upstream, client: 172.18.0.1, server: , request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://172.18.0.2:9000", host: "localhost:8080", referrer: "http://localhost:8080/index.php"

Is there any change that I can make to my very simple configuration files for Nginx or PHP-FPM?
https://github.com/gnarea/docker-alpine-php-fpm/blob/master/nginx.conf.template
https://github.com/gnarea/docker-alpine-php-fpm/blob/master/php-fpm.conf

Thanks in advance!

PHP-FPM Increase Your Page Loading Times By 300% (no replies)

$
0
0
One of the primary objectives of our stack integrations is to improve the speed of the overall processes of our stack. At Cloudways, we valued customer feedback and based on feedback from our clients, we added PHP-FPM and tested it against Apache (mod_php). Our test results show over 300% improvement in website performance.

We have made PHP-FPM as default on Cloudways; we would like you to check the performance of our new ThunderStack i.e. Nginx, Varnish, Apache, PHP-FPM, Memcached, MySQL & PHP. You can do so by signing up for free:

https://platform.cloudways.com/signup

For more details about our tests, read this blog post:

https://www.cloudways.com/blog/php-fpm-on-cloud/

php-fpm 7.1 child exited with code 70 (2 replies)

$
0
0
Hello,
After upgrading to php 7.1 i have at least one a day log entries like this.

[12-Jan-2017 06:58:21] WARNING: [pool xxx] child 8621 exited with code 70 after 34650.677192 seconds from start
[12-Jan-2017 06:58:24] WARNING: [pool yyy] child 749 exited with code 70 after 1606.741001 seconds from start
[12-Jan-2017 06:58:25] WARNING: [pool aaa] child 16281 exited with code 70 after 21167.097724 seconds from start
[12-Jan-2017 06:58:26] WARNING: [pool bbb] child 28951 exited with code 70 after 16304.440978 seconds from start
[12-Jan-2017 06:58:27] WARNING: [pool ccc] child 3832 exited with code 70 after 13587.031634 seconds from start
[12-Jan-2017 06:58:28] WARNING: [pool dddd] child 11432 exited with code 70 after 10654.602095 seconds from start
[12-Jan-2017 06:58:29] WARNING: [pool eeee] child 7058 exited with code 70 after 5.385061 seconds from start
[12-Jan-2017 06:58:31] WARNING: [pool ffff] child 28626 exited with code 70 after 54040.579496 seconds from start
[12-Jan-2017 06:58:41] WARNING: [pool uuuu] child 25614 exited on signal 9 (SIGKILL) after 4475.137768 seconds from start


Somethimes there is only few entries but somethimes several dozens all in the same time.This applies not all my pools but some of them in randow way.
Iteresting is the last one with SIGKILL.

I found this in fpm source code https://github.com/php/php-src/blob/master/sapi/fpm/fpm/fpm.h#L29
but i don't have any idea what is responsible for that kind of behaviour.
I've tried to minimize pm.max_requests=1000 but without any improvement.

Is this a php bug?

php-fpm ignores me (no replies)

$
0
0
I am trying to get php-fpm to process php files from nginx. Nginx is configured as follows

location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_pass unix:/var/run/php.socket;
# fastcgi_pass 127.0.0.1:9000;
}

If I put in a bogus page, I get a not found 404, which indicates the location block is being exected. However, real php pages just display nothing. I turned up logging to debug for php-fpm and fastcgi.logging = 1, but nothing is logged except

[20-Mar-2017 01:50:02.193330] DEBUG: pid 14906, fpm_pctl_perform_idle_server_maintenance(), line 379: [pool www] currently 0 active children, 2 spare children, 2 running children. Spawning rate 1

I tried both the unix socket and the tcp port. The behavior is the same.

LDAP Authentication (no replies)

$
0
0
Hello guys! Can someone help me?
I need to configure LDAP authentication on NGINX.

Here are my settings:

[root@SERVER conf.d]# nginx -V
nginx version: nginx/1.11.13
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --user=nginx--group=nginx --with-file-aio --with-google_perftools_module --with-mail --with-mail_ssl_module --with-threads --with-select_module --with-stream --with-stream_ssl_module --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_geoip_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_mp4_module --with-http_perl_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_stub_status_module --with-http_sub_module --with-http_ssl_module --with-http_stub_status_module --with-pcre --with-http_v2_module --with-http_xslt_module --with-poll_module --add-module=/usr/share/nginx/modules/ngx_pagespeed-1.12.34.2-beta --add-module=/usr/share/nginx/modules/ngx_cache_purge-2.3 --add-module=/usr/share/nginx/modules/ngx_slowfs_cache-1.10 --add-module=/usr/share/nginx/modules/ngx_coolkit-0.2rc3 --add-module=/usr/share/nginx/modules/ngx_headers-more-0.32 --add-module=/root/addons/nginx/nginx-auth-ldap/
[root@SERVER conf.d]#

nginx.conf

ldap_server ldapserver {
url ldap://dominio:3268/DC=dominio,DC=gov,DC=br?sAMAccountName?sub?(objectClass=person);
group_attribute uniquemember;
group_attribute_is_dn on;
binddn "CN=user,OU=Contas Servicos,OU=Administrativa,DC=dominio,DC=gov,DC=br";
binddn_passwd password;
require valid_user;
}

.conf

location / {
proxy_pass http://server.dominio.gov.br;
auth_ldap_servers ldapserver;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;



proxy_redirect http://server.dominio.gov.br/system/login.asp http://site.dominio.gov.br;

}
}

Thank you very much for the help. ;)

Streaming remote files with PHP-FPM and Nginx? (no replies)

$
0
0
I'm trying to stream a file from a remote server to the client. But it seems as though the buffers are messing with something causing the download speed to be much higher than the download speed.

with php fpm as backend upstream sock file.

Remote server -> Nginx server -> Client
How can I have Nginx stream the remote file in a 1:1 ratio?

i dont want nginx first buffer and then send it to me.
But synchronously.

I have mounted rclone /drive as
nextcloud external storage
when i start to download some big file i see it in bmon that my vps is downloading it and serving to me. But when i cancel it, it still is downloading until whole file is loaded somewhere into memory. I have to do service php7.0-fpm restart to make it stop downloading. service nginx restart do nothing.


but i cant find solution, i have every proxy off buffering, still doesnt help.
Please help thanks.

Client browser generating many http errors 499 (no replies)

$
0
0
HI,

I have a website with a high traffic.
And lately I noticed that some users, who mostly use o Google Chrome, but also with Mozilla Firefox have re-transmitted the same request several times. And this is giving us several problems, especially unnecessary resource allocation.

In the NGINX log several requests with the HTTP 499 error code are followed in an interval of a few seconds, being several in the same second. In some cases reaching more than one hundred repeated requests.

The main problem of this is that for each request php-fpm is processing the php code, and in some cases even with access to the database. Even after NGINX having returned the HTTP 499 error.

How can I get NGINX to stop processing php-fpm for this request after the client's browser has disconnected and generated the HTTP 499 error?


Thank you very much if anyone knows how to help me.
Anderson Onir

PHP pages not loading (no replies)

$
0
0
Hi!

I'm trying to make PHP pages work with nginx. It works perfectly like http://www.thunix.org/index.php
but when I try to do http://www.thunix.org/~hexhaxtron/index.php it asks me to Open/Save it instead of loading it.

I need to get it working with for example:

/home/h/hexhaxtron/www/index.php
or
/home/u/username/www/index.php

and also inside other directories like:

/home/h/hexhaxtron/www/abc/foo/bar/index.php

I hope to get this sorted soon.

My /etc/nginx/nginx.conf file is:

user www-data;
worker_processes 1;

error_log /var/log/nginx/error.log;
#error_log /var/log/nginx/error.log notice;
#error_log /var/log/nginx/error.log info;

#pid /var/run/nginx.pid;


events {
worker_connections 1024;
use epoll;
}


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"';

#access_log /var/log/nginx/access.log main;

sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 65;

#gzip on;

include conf.d/*.conf;

server {
listen 80;
server_name localhost;
root /srv/www/htdocs/;

#charset koi8-r;

#access_log /var/log/nginx/host.access.log main;

location / {
index index.html index.htm index.php;
}

location ~ /~(?<firstchar>.)(?<resofuser>[^/]+)/(?<rest>.*) {
alias /home/$firstchar/$firstchar$resofuser/www/$rest;
}

location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
}

# UserDir with PHP
location ~ /~(?<firstchar>.)(?<resofuser>[^/]+)/(?<rest>.*\.php) {
alias /home/$firstchar/$firstchar$resofuser/www/$rest;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
}

location ~ \.cgi$ {
gzip off;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
include fastcgi_params;
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /srv/www/htdocs/;
}

listen 443 ssl;
server_name thunix.org;


ssl_certificate /etc/letsencrypt/live/thunix.org/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/thunix.org/privkey.pem;
}

server {
listen 80;
server_name localhost;
root /srv/www/htdocs/;

#charset koi8-r;

#access_log /var/log/nginx/host.access.log main;

# UserDir with PHP
location ~ /~(?<firstchar>.)(?<resofuser>[^/]+)/(?<rest>.*\.php) {
alias /home/$firstchar/$firstchar$resofuser/www/$rest;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
}

location / {
index index.html index.htm index.php;
}

location ~ /~(?<firstchar>.)(?<resofuser>[^/]+)/(?<rest>.*) {
alias /home/$firstchar/$firstchar$resofuser/www/$rest;
}

location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
}

# UserDir with PHP
location ~ /~(?<firstchar>.)(?<resofuser>[^/]+)/(?<rest>.*\.php) {
alias /home/$firstchar/$firstchar$resofuser/www/$rest;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
}

location ~ \.cgi$ {
gzip off;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
include fastcgi_params;
}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /srv/www/htdocs/;
}

listen 443 ssl default_server;
server_name www.thunix.org;


ssl_certificate /etc/letsencrypt/live/www.thunix.org/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/www.thunix.org/privkey.pem;
}


include vhosts.d/*.conf;



###Config for Round Cube
server {
listen 80;
server_name www.thunix.org thunix.org;
root /srv/www/htdocs/webmail;

if ($http_host != "www.thunix.org") {
rewrite ^ http://www.thunix.org$request_uri permanent;
}

index index.php index.html;

location ~ ^/favicon.ico$ {
root /srv/www/htdocs/webmail/skins/default/images;
log_not_found off;
access_log off;
expires max;
}

location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}

location ~ ^/(README|INSTALL|LICENSE|CHANGELOG|UPGRADING)$ {
deny all;
}
location ~ ^/(bin|SQL)/ {
deny all;
}

# Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}

location ~ \.php$ {
try_files $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index index.php;
}
}
}

Permission denied) while reading upstream (no replies)

$
0
0
Dear i got this error msg please help

[code]

2017/09/17 22:04:05 [crit] 1278#0: *13 open() "/var/lib/nginx/tmp/fastcgi/1/00/0000000001" failed (13: Permission denied) while reading upstream, client: 151.255.87.244, server: _, request: "GET /scof/scof.php?hash=es2 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm/php-fpm.sock:", host: "imoham3d.ml"
2017/09/17 22:04:05 [crit] 1278#0: *18 open() "/var/lib/nginx/tmp/fastcgi/2/00/0000000002" failed (13: Permission denied) while reading upstream, client: 51.36.218.237, server: _, request: "GET /scof/scof.php?hash=es2 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm/php-fpm.sock:", host: "imoham3d.ml"
2017/09/17 22:04:06 [crit] 1278#0: *23 open() "/var/lib/nginx/tmp/fastcgi/3/00/0000000003" failed (13: Permission denied) while reading upstream, client: 5.41.16.159, server: _, request: "GET /scof/scof.php?hash=es2 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm/php-fpm.sock:", host: "imoham3d.ml"
2017/09/17 22:04:06 [crit] 1278#0: *34 open() "/var/lib/nginx/tmp/fastcgi/4/00/0000000004" failed (13: Permission denied) while reading upstream, client: 94.129.167.156, server: _, request: "GET /scof/scof.php?hash=es2 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm/php-fpm.sock:", host: "imoham3d.ml"

[/code]

auth_request called multiple times for same single request (no replies)

$
0
0
Hello, thanks to the support of this forum I managed to configure nginx to use the http_auth_request module to intercept a file upload request and verify there is enough disk space left to store the file, rejecting the request if there isn't.

This works fine for smaller files; the auth_request redirects to the php script which either validates (returning 200) or rejects the request (returning 403).

When I attempt to upload a file of 1GB in size the POST request is sent, processed for 2 minutes and returns with a 'failed net::ERR_CONNECTION_RESET'

From php logging I can see that while the POST request is being processed the 'pcapAuthUploadScript.php' is called 4/5 times. Each time the script appears complete with the expected 403 however the POST request does not return.

The failed POST request can be seen in the browser network debug view however the 'Request Headers' section states that only 'Provisional headers are shown' and detail such as the 'Content-Length' is not available which suggests (to me) that the request has not been accepted.

The odd thing is that this works in a virtual machine environment, it was just during testing on an actual piece of hardware (essentially just a PC in a crate) that we get this problem.

The next step will be to get a debug version of nginx setup to see if there is any indication of the problem, the default nginx error log is not reporting any problems.

Given that this is all fairly new to me I would appreciate if someone could cast their eye over my configuration and php script in case i have missed something obvious.

In the nginx configuration file i have:

...

location /api/analysis/upload {
auth_request /bigfile/auth;
error_page 403 =413 /lowDiskSpace.html;
error_page 413 /fileTooBigError.html

fastcgi_request_buffering off;
fastcgi_read_timeout 1h;
fastcgi_pass unix:/opt/tmp/php-fpm.sock;

include fastcgi_params;
fastcgi_param PERMITTED_FILETYPE "bigf";
fastcgi_param HOME_FOLDER "/home/instrument";
fastcgi_param DEST_FOLDER "Analysis/Filters";
fastcgi_param SCRIPT_FILENAME $document_root/PHP/uploadFile.php;
}

location /bigfile/auth {
internal;

fastcgi_pass_request_body off;
fastcgi_pass_request_headers off;
fastcgi_pass unix:/opt/tmp/php-fpm.sock;
fastcgi_intercept_errors on;

include fastcgi_params;
fastcgi_param BIGFILE_UPLOAD_SIZE $content_length;
fastcgi_param BIGFILE_UPLOAD_MARGIN_BYTES 10737418240;
fastcgi_param HOME_FOLDER "/home/instrument";
fastcgi_param DEST_FOLDER "Analysis/Filters";
fastcgi_param SCRIPT_FILENAME $document_root/PHP/pcapAuthUpload.php;
}

...

My script doesn't do very much:

<?php
// The size of the upload request is passed in here (represents the file size plus a little for the http header)
$upload_target_size = $_SERVER['BIGFILE_UPLOAD_SIZE'];
// The intended destination for the file being uploaded
$upload_target_dir = $_SERVER['HOME_FOLDER'] . "/" . $_SERVER['DEST_FOLDER'];
// Permissible minimum free space in bytes after the intended upload
$upload_margin = $_SERVER['BIGFILE_UPLOAD_MARGIN_BYTES'];

// How much space do we currently have?
$space_available = diskfreespace($upload_target_dir);

error_log('space_available = ' . $space_available . ' bytes.');

if (($space_available - $upload_target_size) > $upload_margin) {
http_response_code(200);
exit('upload request validated');
}

http_response_code(403);
error_log('not enough disk space to safely upload the file!');
?>

In both working and failing scenarios I have dumped the $_SERVER variable received by my script, it looks like the following:

...

[19-Sep-2017 15:50:04 UTC] Array
(
[USER] => instrument
[HOME] => /home/instrument
[FCGI_ROLE] => RESPONDER
[QUERY_STRING] =>
[REQUEST_METHOD] => POST
[CONTENT_TYPE] => multipart/form-data; boundary=----WebKitFormBoundaryJvDVM6DSgXzw7dCv
[CONTENT_LENGTH] =>
[SCRIPT_NAME] => /bigfile/auth
[REQUEST_URI] => /api/analysis/upload
[DOCUMENT_URI] => /bigfile/auth
[DOCUMENT_ROOT] => /opt/lib/endor
[SERVER_PROTOCOL] => HTTP/1.1
[GATEWAY_INTERFACE] => CGI/1.1
[SERVER_SOFTWARE] => nginx/1.13.0
[REMOTE_ADDR] => 192.168.202.49
[REMOTE_PORT] => 56951
[SERVER_ADDR] => 127.0.0.1
[SERVER_PORT] => 8000
[SERVER_NAME] =>
[PATH_INFO] =>
[SCRIPT_FILENAME] => /opt/lib/PHP/pcapAuthUpload.php
[REDIRECT_STATUS] => 200
[PHP_VALUE] => upload_max_filesize=10G
post_max_size=10G
[BIGFILE_UPLOAD_SIZE] => 1135591215
[BIGFILE_UPLOAD_MARGIN_BYTES] => 10737418240
[HOME_FOLDER] => /home/instrument
[DEST_FOLDER] => Analysis/Filters
[PHP_SELF] => /pcap/auth
[REQUEST_TIME_FLOAT] => 1505836204.8134
[REQUEST_TIME] => 1505836204
[argv] => Array
(
)

[argc] => 0
)

[19-Sep-2017 15:50:04 UTC] not enough disk space to safely upload the file!

Many thanks for reading

How should I create an alias outside the root directory in nginx? (1 reply)

$
0
0
Hi,

I am trying to create a protected directory that is outside the documents in the root directory.

I tried to place an alias to a directory external to the root directory of the server, but I am having trouble responding to PHP scripts.

The error he shows me is "File not found."

/var/www/website.com/htdocs <---- (all files that are public) www.website.com
/var/www/website.com/admdb <---- (only private files) www.website.com/admdb


## Serves https://www.website.com
server {
server_name www.website.com;
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server ipv6only=on;

resolver 8.8.8.8 8.8.4.4 valid=300s;

ssl_certificate /etc/letsencrypt/live/website.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/website.com/privkey.pem;

include /etc/nginx/snippets/diffie-hellman;

root /var/www/website.com/htdocs;

index index.php index.html index.htm;

include /etc/nginx/snippets/security;

location / {
try_files $uri $uri/ =404;
}

location /sendy {
access_log off;
error_log off;
rewrite ^/sendy/(l|t|w)/([a-zA-Z0-9\/]+)$ /sendy/$1.php?i=$2&$args;
rewrite ^/sendy/(u?n?subscribe)/(.*)$ /sendy/$1.php?i=$2&$args;
try_files $uri $uri/ $uri.php?$args;
}

location ^~ /admdb {

alias /var/www/website.com/admdb;

#auth_basic "Restricted Content";
#auth_basic_user_file /etc/nginx/.htpasswd;

# FIX ME
location ~ \.php$ {
include /etc/nginx/fastcgi.conf;
fastcgi_param DOCUMENT_ROOT /var/www/website.com/admdb;
fastcgi_pass 127.0.0.1:9007;
}
}

location ~ \.php$ {
include /etc/nginx/fastcgi.conf;
fastcgi_pass 127.0.0.1:9007;
}

}


regards.
Viewing all 219 articles
Browse latest View live