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

how to intercept upload file error? (no replies)

$
0
0
Hi,
I'm using nginx and a fastcgi service to upload some audio-video contents.
This is my conf:
location /catramms/binary {
if ($request_method = POST) {
rewrite ^/catramms/binary/([0-9]+)/?$ /authorization?method=uploadBinary&ingestionJobKey=$1&X-Progress-ID=$1 last;
}

location /authorization {
auth_request /checkAuthorization;

client_body_temp_path /tmp;

client_body_in_file_only on;

proxy_pass_request_headers on;

proxy_set_header X-FILE $request_body_file;

proxy_redirect off;
proxy_set_body off;
proxy_http_version 1.1;
proxy_pass http://127.0.0.1:8080/catramms/uploadedBinary;

track_uploads uploads 5s;

location = /checkAuthorization {
internal;

proxy_pass http://127.0.0.1:8080/catramms/authorization;
proxy_pass_request_body off;
proxy_set_header Content-Length "";
proxy_set_header X-Original-METHOD $request_method;
proxy_set_header X-Original-URI $request_uri;
}
}
}

The request is a POST with the content/file attached (something like curl -v -X POST -u aaa:bbb -T <myfile>.avi http://.../catramms/binary/16

In case of an error during the upload of the file (i.e. internet connection down), nginx returns an error but I need the error, with the temporary filename,
is proxied to a service.
Can I configure nginx in order to have this call in case of the error?

Thanks
Giuliano

413 Request Entity Too Large (no replies)

$
0
0
Hi,

I have set the below settings.

/etc/php.ini
max_input_time = 60
max_execution_time = 200
upload_max_size = 100M
upload_max_filesize = 100M
post_max_size = 100M

/opt/nginx/conf/nginx.conf
client_max_body_size 100M;

I am encountering 413 Request Entity Too Large nginx/1.12.1 while uploading file of size 6MB. Any help will be highly appreciable. Thanks in Advance.

Best Regards,

PHP5-FPM 502 Bad Gateway error on virtual host (1 reply)

$
0
0
I have an iRedMail installation running php5-fpm and i setup a second website using virtual host.

The website it self works but i cant get php on the virtual host, it gives me a 502 error every time.

my virtual config is /etc/nginx/conf.d/virtual.conf
and my 2 php pools are in /etc/php5/fpm/pool.d/www.conf & /etc/php5/fpm/pool.d/www2.conf

here is my second pool file
https://prnt.sc/lzp45v

here is my virtual.conf
https://prnt.sc/lzp42d

PHP fpm config with WP site (2 replies)

$
0
0
Hi Everyone,

I have a wordpress site running with following configuration:

Server
Memory: 32G
VCPUs: 8
Daily visitors: About 4000 Visitors/day

Mysql Server (Separate)
Memory: 15G
VCPUs: 4

pm = dynamic
pm.max_children = 750
pm.start_servers = 400
pm.min_spare_servers = 400
pm.max_spare_servers = 600
pm.process_idle_timeout = 10s;
pm.max_requests = 500;

I have a custom wordpress posts with lot of fields. The issue is whenever I try to edit/add posts on my wordpress admin it keeps on loading
and returns 504 header. I have about 4000 visitors on my site daily. Can anyone please suggest the correct configuration for the php for my site?
Please let me know if you have any questions.

Error 502 Bad Gateway on nginx and php-fpm (no replies)

$
0
0
I can't start php7-fpm in supervisor. The error log:

unable to bind listening socket for address '127.0.0.1:9000': Address in > use (98)

In browser:

localhost:8090 is error: 502 Bad Gateway

netstat -tulnp

tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 13/nginx
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 13/nginx
tcp 0 0 0.0.0.0:8090 0.0.0.0:* LISTEN 13/nginx
tcp 0 0 :::3000 :::* LISTEN 11/node
tcp 0 0 :::7000 :::* LISTEN 10/node
ps aux

/ # ps aux
PID USER TIME COMMAND
1 root 0:00 {bootloader} /bin/sh /boot/bootloader
8 root 0:01 {supervisord} /usr/bin/python2 /usr/bin/supervisord
62 root 0:00 /bin/sh
92 root 0:00 nginx: master process /usr/sbin/nginx
93 root 0:00 nginx: worker process
94 root 0:00 nginx: worker process
122 root 0:00 ps aux
php-fpm.d/www/conf

[www]

user = nobody
group = nobody

listen = 127.0.0.1:9000

pm = dynamic

pm.max_children = 5

pm.start_servers = 2

pm.min_spare_servers = 1

pm.max_spare_servers = 3
/etc/nginx/sites-enabled/page1

server {
listen 8090;
root /usr/bin;
server_name localhost;
access_log /dev/null;
error_log /dev/null;

location / {
proxy_pass http://127.0.0.0:7000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Fowarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Fowarded-Proto $scheme;
proxy_cache_bypass $http_upgrade;

try_files $uri $uri/ =404;
}

location ~ \.(gif) {
root /var/lib;
}

}
/etc/nginx/sites-enabled/page2

server {
server_name localhost;
root /www;
index index.php;
access_log /dev/null;
error_log /dev/null;

client_max_body_size 100M;
fastcgi_read_timeout 1800;

location / {
try_files $uri $uri/ /index.php$query_string;
}

location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
access_log off;
}

location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
}
}
Where is error? I don't just any idea.

nginx, grpc and client body buffering (no replies)

$
0
0
Hello,

Seems like when using grpc on nginx 1.16.x the client body is _always_ buffered on the disk. Yeah, seems absolutely weird, but:

1) here's the $request_lengths (not $body_bytes_sent), top 25 unique entries:

[root@b0 nginx]# cat /var/log/nginx/balancer/foo.bar.tld-access.log | awk -F\" '{print $3}' | awk '{print $3}' | sort -urn | head -n 25
1272
1080
308
307
306
305
304
303
302
301
300
299
298
297
296
295
275
274
273
272
271
270
269
268
126

2) in the same time these were collected I got gazillions of "a client request body is buffered to a temporary file" log entries for a given vhost.
3) this nginx instance is running with client_body_buffer_size 128k;
4) no other vhosts except this one - gRPC-enabled, are complaining about this with what seems to be a 100% hitrate. I mean, yeah, they do complain sometimes, with a rate that seems reasonable. But here I got several dozens of gigs of log messages per day about buffering. In the same time I just don;t see in logs request_lengths close or comparable with 128k.
5) I've checked the same in PHP - the pool thinks the content-length for POSTS was very small too, similar to what nginx is reporting.

I'm not creating a ticket on this only because I still think I'm missing something, and yeah, it seems weird. Have someone seen something similar ?

Thanks.
Eugene.

nginx image filter: image gets rotated instead of crop (no replies)

$
0
0
Hello,

I have an old and proven to work config like this (like, literally, for dozen of years):

server {
listen 8085 default;
listen [::]:8085 default;

root /usr/local/public/storage;

location ~ ^/resize/([\d\-]+)x([\d\-]+)/(.+) {
set $width $1;
set $height $2;
rewrite ^/resize/([\d\-]+)x([\d\-]+)/(.+) /$3 break;
image_filter resize $width $height;
image_filter_buffer 10M;
image_filter_jpeg_quality 85;
}

location ~ ^/crop/([\d\-]+)x([\d\-]+)/(.+) {
set $width $1;
set $height $2;
rewrite ^/crop/([\d\-]+)x([\d\-]+)/(.+) /$3 break;
image_filter crop $width $height;
image_filter_buffer 10M;
image_filter_jpeg_quality 85;
}
}

(yeah, I'm awared that it's better to use all of this with secure link module, but this is a temporary test). This config works quite well, but suddenly some "vertical" images gets rotated instead of cropping:

original:
https://storage.test.tpark-it.ru/temp/2a569fff220c6d40cbb43ae65c142028.jpg

derivative:
https://storage.test.tpark-it.ru/crop/100x100/temp/2a569fff220c6d40cbb43ae65c142028.jpg (notice it's rotated)

Why is that ? Really cannot figure this out. Seems like this is the only pic so far. Others seems to do well:

https://storage.test.tpark-it.ru/3641f5e9a89b8eb49eae2d408235fad9.png
https://storage.test.tpark-it.ru/crop/100x-/3641f5e9a89b8eb49eae2d408235fad9.png

Does this have something to do with the fact that this "bad" pic is "vertical" ?

Thanks.

Getting 400 Bad Request on .js.php Files (no replies)

$
0
0
Hello Group,
we have a website running with an upload for media files. When i want to upload media then the following error is sent back to the browser:

upload:524 GET https://server.domain.name/swfuploader/upload.js.php?app=frontend&env=prod&debug=false&version=1613649786 net::ERR_ABORTED 400 (Bad Request)

Other php-based files are delivered correctly. Can u please help me to fix this?
Thank you!

How to properly set fastcgi_param SCRIPT_FILENAME - nothing seems to work (1 reply)

$
0
0
Sorry for this noob question, but frustration is eating me.
I'm trying to set up my php app for 2 straight days, and no config seems to work to load it properly.

My config:

server {
server_name mydomain.com;
...
...

fastcgi_param HTTPS on;

location /app {
index index.php;
alias /var/www/app;

location ~ \.php$ {
try_files $uri =404;
include /etc/nginx/fastcgi_params;
include /etc/nginx/fastcgi.conf;

fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/var/run/nginx/php-fastcgi.sock;
}
}
}
But I also tried a number of other placements and combinations.

This will result (probably obviously) in a "No input file specified."

SCRIPT_FILENAME will never be taken unless I change it explicitly to /var/www/app/index.php (and in that case only that file loads, 404ing all other php files out).

What could be the issue? Where could I even debug this? (in terms of what file nginx is trying to feed php-fpm)

PHP Configuration with nginx (1 reply)

$
0
0
Hello everyone,

I try to configure PHP with an nginx server (with this instruction https://www.cyberciti.biz/faq/how-to-install-php-on-opensuse-15-2-15-1/ ), but get 404 NOT FOUND when try URL http://127.0.0.1/index.php . My nginx.conf file:

worker_processes 1;


events {
worker_connections 1024;
use epoll;
}


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

sendfile on;

keepalive_timeout 65;


include conf.d/*.conf;

server {
listen 80;
server_name localhost;

#charset koi8-r;

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

location / {
root /srv/www/htdocs/;
index index.html index.htm;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /srv/www/htdocs/;
}

# PHP config #
location ~ \.php$ {
# 404
try_files $fastcgi_script_name =404;

# default fastcgi_params
include /etc/nginx/fastcgi_params;

# fastcgi settings
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;

# fastcgi params
fastcgi_param DOCUMENT_ROOT $realpath_root;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
}
}



include vhosts.d/*.conf;

}

What could be a reason of this?

Wordpress url prefix nginx Subdomain / Subfolder (no replies)

$
0
0
Hi
I'm runing Nginx in Webmi/Virtualmin server
I read more about configuration for URL Prefix and Now I'm confusing ...
Would you please read?

1-What is different between these to lines? I copied the first one from this link https://www.nginx.com/resources/wiki/start/topics/recipes/wordpress/

try_files $uri $uri/ /index.php?$args;
try_files $uri $fastcgi_script_name =404;

2-I want to add nginx config for my subdomain , because now I have only main page of WordPress of website and want to see other pages , in your default configuration is like this :

server {server_name blog.virtualmin.com www.blog.virtualmin.com;
listen my ip v4;
root /home/webmin/domains/blog.virtualmin.com/public_html;
index index.php index.htm index.html;
access_log /var/log/virtualmin/blog.virtualmin.com_access_log;
error_log /var/log/virtualmin/blog.virtualmin.com_error_log;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
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_FILENAME /home/webmin/domains/blog.virtualmin.com/public_html$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT /home/webmin/domains/blog.virtualmin.com/public_html;
fastcgi_param SERVER_PROTOCOL $server_protocol;
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 PATH_INFO $fastcgi_path_info;
fastcgi_param HTTPS $https;
location ~ \.php(/|$) {
try_files $uri $fastcgi_script_name =404;
fastcgi_pass unix:/var/php-nginx/162886556426955.sock/socket;
}
fastcgi_split_path_info ^(.+\.php)(/.+)$;
listen my ip v4:443 ssl;
ssl_certificate /home/webmin/domains/blog.virtualmin.com/ssl.combined;
ssl_certificate_key /home/webmin/domains/blog.virtualmin.com/ssl.key;
fastcgi_read_timeout 60;
}

And I add these 2lines from the link of my first question

location /home/webmin/domains/blog.virtualmin.com {
try_files $uri $uri/ /home/webmin/domains/blog.virtualmin.com/index.php?$args;
}

location ~ \.php$ {
fastcgi_split_path_info ^(/home/webmin/domains/blog.virtualmin.com)(/.*)$;
}

And also I change the url of those links in many way, but it didn’t worked.
Would you please tell me what should I do for that ?

3-How add permalink for my subfolder inside the root folder of wordpress ? I was restored my website from Cpanel to Wbemin/Virtualmin powerful panel and all urls

Thanks to Nginx Developers and support team for this amazing Webserver that can compit the Lightspeed.

Browser downloads php pages (1 reply)

$
0
0
Hi,

As I explained everything here :
https://serverfault.com/questions/1077642/browser-downloads-the-file-instead-of-opening-php-files

my main problem is that : either the php page I try to access from http://www.my_domain.com/index.php is downloaded, either it return the 50x.html error file.

For the config files, I have the nginx.conf int he root /nginx folder and the /conf.d/default.conf
I'm not that so comfortable with the /site-available and /sites-enabled folder as they are not included in my /nginx folder naturally, as though I created them for my subdomains.

I haven't configures certbot yet, as the php doesn't work I don't want to make it more difficult, and I know Certbot can rewrite the default.conf file if necessary.

#######################################
## Config files ##
# #
# my domain name is anonymised as #
# my_domain.com #
# #
## ##
######################################

the nginx.conf is as follow :
user nginx;

worker_processes auto;

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

pid /var/run/nginx.pid;


events {
worker_connections 1024;

}

http {
include /etc/nginx/mime.types;
include /etc/nginx/sites-available/*.conf;
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 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;

}

and the default.conf is as follows :
server {
listen 80;
server_name gout-cha.com www.gout-cha.com;

location / {
root /var/www/www.gout-cha.com;
index index.php index.html index.htm;
}

#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 /var/www/www.gout-cha.com;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
#if (!-f $document_root$fastcgi_script_name) {
# return 404;
#}
root /var/www/www.gout-cha.com;
# fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
fastcgi_pass unix:/var/run/php-fpm.sock;
}


}

The /var/log/nginx/error.log file is as follows (since the last "$ sudo service nginx reload && sudo service php7.4-fpm restart") :
2021/09/20 20:08:38 [notice] 11708#11708: signal 1 (SIGHUP) received from 41584, reconfiguring
2021/09/20 20:08:38 [notice] 11708#11708: reconfiguring
2021/09/20 20:08:38 [notice] 11708#11708: using the "epoll" event method
2021/09/20 20:08:38 [notice] 11708#11708: start worker processes
2021/09/20 20:08:38 [notice] 11708#11708: start worker process 41585
2021/09/20 20:08:38 [notice] 11708#11708: start worker process 41586
2021/09/20 20:08:38 [notice] 41517#41517: gracefully shutting down
2021/09/20 20:08:38 [notice] 41517#41517: exiting
2021/09/20 20:08:38 [notice] 41517#41517: exit
2021/09/20 20:08:38 [notice] 41518#41518: gracefully shutting down
2021/09/20 20:08:38 [notice] 41518#41518: exiting
2021/09/20 20:08:38 [notice] 41518#41518: exit
2021/09/20 20:08:38 [notice] 11708#11708: signal 17 (SIGCHLD) received from 41517
2021/09/20 20:08:38 [notice] 11708#11708: worker process 41517 exited with code 0
2021/09/20 20:08:38 [notice] 11708#11708: worker process 41518 exited with code 0
2021/09/20 20:08:38 [notice] 11708#11708: signal 29 (SIGIO) received
2021/09/20 20:09:03 [error] 41585#41585: *508 open() "/var/www/www.my_domain.com/favicon.ico" failed (2: No such file or directory), client: 90.22.169.35, server: my_domain.com, request: "GET /favicon.ico HTTP/1.1", host: "www.my_domain.com", referrer: "http://www.my_domain.com/index.html"
2021/09/20 20:09:10 [crit] 41585#41585: *507 connect() to unix:/var/run/php7.4-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 90.22.169.35, server: my_domain.com, request: "GET /index.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php7.4-fpm.sock:", host: "www.my_domain.com"
2021/09/20 20:09:18 [crit] 41585#41585: *507 connect() to unix:/var/run/php7.4-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 90.22.169.35, server: my_domain.com, request: "GET /test.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php7.4-fpm.sock:", host: "www.my_domain.com"
2021/09/20 20:14:13 [crit] 41585#41585: *511 connect() to unix:/var/run/php7.4-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 107.189.14.98, server: my_domain.com, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php7.4-fpm.sock:", host: "47.242.156.85:80"
2021/09/20 20:26:23 [error] 41585#41585: *513 open() "/var/www/www.my_domain.com/robots.txt" failed (2: No such file or directory), client: 116.202.35.125, server: my_domain.com, request: "GET /robots.txt HTTP/1.1", host: "my_domain.com"
2021/09/20 20:26:23 [crit] 41585#41585: *514 connect() to unix:/var/run/php7.4-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 116.202.35.125, server: my_domain.com, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php7.4-fpm.sock:", host: "my_domain.com"
2021/09/20 20:30:26 [error] 41585#41585: *517 open() "/var/www/www.my_domain.com/robots.txt" failed (2: No such file or directory), client: 45.95.147.3, server: my_domain.com, request: "HEAD /robots.txt HTTP/1.0"

Thanks a lot for any help.

php-fpm long delay before returning output (no replies)

$
0
0
Hello,

The problem I'm experiencing: randomly, some requests take an extra 20 seconds, up to 60s to finish.

Manually running curl shows the following behavior:
- curl example.com/api
- 2 seconds - nothing happens (this would be processing time)
- 0.5-1 seconds - json output (stopping in the middle of things like div class="aa )
- 20+ seconds - no output
- last second - the remaining 1-2 lines of the request output are displayed
- request finishes


I expect to not have the 20+ seconds delay where nothing happens.



Here is an example Instana trace showing the error: https://user-images.githubusercontent.com/1954578/162889849-8a2445c0-55b2-4d3b-ba88-a2e89b225dfb.png
Notice this supports the CURL output that PHP has processed the request in 2 seconds.

I have captured a tcpdump of the communication: https://user-images.githubusercontent.com/1954578/162890064-81d8328d-cb20-4d96-8f06-4d67a0006f95.png

To note that the lat FCGI_STDOUT packet is delayed by 50+ seconds, and it contains a few bytes(in this case the json closing paramthesis "]}}" ):

FastCGI (FCGI_STDOUT)
Version: 1
Type: FCGI_STDOUT (6)
Request ID: 1
Content Length: 6
Padding Length: 2
Content Data: 5c6e225d5d7d
Padding Data: 0000

FastCGI (FCGI_STDOUT)
Version: 1
Type: FCGI_STDOUT (6)
Request ID: 1
Content Length: 6
Padding Length: 2
Content Data: 5c6e225d5d7d
Padding Data: 0000


My php-fpm settings:

# php-fpm -v
PHP 7.4.28 (fpm-fcgi) (built: Mar 29 2022 03:26:54)
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.28, Copyright (c), by Zend Technologies



[www]
user = www-data
group = www-data
listen.owner = www-data
listen.group = www-data
listen = 0.0.0.0:9000
listen.backlog = 1024
process.priority = 0
pm = dynamic
pm.min_spare_servers = 5
pm.max_spare_servers = 10
pm.process_idle_timeout = 55
pm.max_children = 100
pm.start_servers = 10
pm.max_requests = 10000
slowlog = /var/log/php-fpm/slowlog.log
request_slowlog_timeout = 10
request_terminate_timeout = 600
user = www-data
catch_workers_output = yes
security.limit_extensions = .php .phar
pm.status_path = /status
php_admin_value[memory_limit] = 512M
php_admin_value[post_max_size] = 256M
php_admin_value[upload_max_filesize] = 256M
php_admin_value[max_execution_time] = 60
php_admin_value[opcache.revalidate_freq] = 0
php_admin_value[opcache.validate_timestamps] = 0
php_admin_value[opcache.max_accelerated_files] = 32531
php_admin_value[opcache.memory_consumption] = 512M
php_admin_value[opcache.interned_strings_buffer] = 128
php_admin_value[opcache.huge_code_pages] = 0
php_admin_value[zend.assertions] = 0
php_admin_value[max_input_vars] = 2000


My nginx settings:

# nginx -v
nginx version: nginx/1.20.1


upstream php {
server 127.0.0.1:9000;
}

server_tokens off;
server_names_hash_bucket_size 256;
client_max_body_size 256m;

server {
listen 80;
server_name xxx;

root /usr/share/xxx/public_api;
index index.php;
try_files $uri $uri/ /index.php?$args;

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

client_header_timeout 120;
client_body_timeout 120;
send_timeout 120;
keepalive_timeout 60;

gzip on;
gzip_comp_level 4;
gzip_proxied any;
gzip_types application/atom+xml application/javascript application/json application/rss+xml
application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json
application/xhtml+xml application/xml font/opentype image/svg+xml image/x-icon text/css
text/plain text/x-component;

location ~ \.php$ {
fastcgi_connect_timeout 60s;
fastcgi_read_timeout 120s;
fastcgi_send_timeout 120s;

fastcgi_pass php;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;

fastcgi_param APPLICATION_ENV live;
fastcgi_param HTTPS off;

opentracing_fastcgi_propagate_context;
}
}

Nginx and PHP-FastCGI Process Manager (no replies)

$
0
0
Hi,

I am using nginx web server and php-fpm backend service to process all php files. NGINX proxies web requests and passes them on to PHP-FPM worker processes that execute the PHP application. Is there a way to capture both response header and body which are processed by PHP-FPM application? Also does the php-fpm response contain only header and body or anything else in response to nginx web server?

I have also enabled https://www.drupal.org/project/http_client_log. Whenever I hit any URL, I do not see any activity seen in https://drupalcms.mydomain.com/admin/reports/http-client-log. Do I need to configure anything else in http-client-log? I am interested in finding out the response header and body from php fpm backend services which is an upstream server to Nginx web server.

OS Version
CentOS Linux release 7.9.2009 (Core)

php -v
PHP 7.4.33 (cli) (built: Nov 10 2022 16:47:47) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.33, Copyright (c), by Zend Technologies

# rpm -qa | grep php
php74-pecl-zip-1.19.0-1.el7.ius.x86_64
php74-common-7.4.33-1.el7.ius.x86_64
php74-pdo-7.4.33-1.el7.ius.x86_64
php74-bcmath-7.4.33-1.el7.ius.x86_64
php74-cli-7.4.33-1.el7.ius.x86_64
php74-pecl-msgpack-2.1.0-1.el7.ius.x86_64
php74-fpm-7.4.33-1.el7.ius.x86_64
php74-pecl-redis-5.2.2-1.el7.ius.x86_64
php74-fpm-nginx-7.4.33-1.el7.ius.noarch
php74-mysqlnd-7.4.33-1.el7.ius.x86_64
php74-gd-7.4.33-1.el7.ius.x86_64
php74-sodium-7.4.33-1.el7.ius.x86_64
php74-opcache-7.4.33-1.el7.ius.x86_64
php74-json-7.4.33-1.el7.ius.x86_64
php74-pecl-igbinary-3.1.2-1.el7.ius.x86_64
php74-mbstring-7.4.33-1.el7.ius.x86_64
php74-xml-7.4.33-1.el7.ius.x86_64
#

#mysql -V
mysql Ver 14.14 Distrib 5.7.40, for Linux (x86_64) using EditLine wrapper

#nginx -v
nginx version: nginx/1.22.1

I will appreciate it if someone can pitch in for help for my post to this mailing list. Please guide me with examples Thanks in advance.

Best Regards,

Kaushal

php8.2-fpm permission denied (no replies)

$
0
0
I have upgraded an existing php-fpm 7.4 installation to 8.2. I don't have problems using 7.4
I am using www-data as user in both nginx and php8.2.fpm
I am using socket connection between services
I am not running selinux

nginx.conf:

user www-data;

site config:

location ~ '\.php$|^/update.php' {
fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
# Ensure the php file exists. Mitigates CVE-2019-11043
try_files $fastcgi_script_name =404;
# Security note: If you're running a version of PHP older than the
# latest 5.3, you should have "cgi.fix_pathinfo = 0;" in php.ini.
# See http://serverfault.com/q/627903/94922 for details.
include fastcgi_params;
# Block httpoxy attacks. See https://httpoxy.org/.
fastcgi_param HTTP_PROXY "";
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param QUERY_STRING $query_string;
fastcgi_intercept_errors on;

fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
}

/etc/php/8.2/fpm/pool.d/www.conf:

user = www-data
group = www-data

listen = /var/run/php/php8.2-fpm.sock


ls -l /var/run/php/php8.2-fpm.sock;
srw-rw---- 1 www-data www-data 0 Jan 24 14:43 /var/run/php/php8.2-fpm.sock

nginx/error.log

2023/01/24 15:32:46 [error] 82564#82564: *1 FastCGI sent in stderr: "PHP message: PHP Warning: require(/var/www/grammartiste.com/web/vendor/autoload.php): Failed to open stream: Permission denied in /var/www/grammartiste.com/web/autoload.php on line 16PHP message: PHP Fatal error: Uncaught Error: Failed opening required '/var/www/grammartiste.com/web/vendor/autoload.php' (include_path='.:/usr/share/php') in /var/www/grammartiste.com/web/autoload.php:16
Stack trace:
#0 /var/www/grammartiste.com/web/index.php(14): require_once()
#1 {main}
thrown in /var/www/grammartiste.com/web/autoload.php on line 16" while reading response header from upstream, client: 202.90.245.199, server: grammartiste.com, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php8.2-fpm.sock:", host: "grammartiste.com"

ls -l /var/www/grammartiste.com/web/vendor/autoload.php
-rwxrwxrwx 1 www-data www-data 771 Jan 24 13:00 /var/www/grammartiste.com/web/vendor/autoload.php

ls -l /var/www/grammartiste.com/web/vendor/autoload.php
-rwxrwxrwx 1 www-data www-data 771 Jan 24 13:00 /var/www/grammartiste.com/web/vendor/autoload.php

ls -l /usr/share/php
total 184
drwxr-xr-x 3 root root 4096 Jan 24 12:29 8.2
drwxr-xr-x 2 root root 4096 Jan 24 12:29 Archive
drwxr-xr-x 25 root root 4096 Nov 10 03:03 Composer
drwxr-xr-x 2 root root 4096 Jan 24 12:29 Console
drwxr-xr-x 5 root root 4096 Nov 10 03:03 data
drwxr-xr-x 2 root root 4096 Nov 8 12:17 DB
-rw-r--r-- 1 root root 43744 May 2 2020 DB.php
drwxr-xr-x 7 root root 4096 Nov 10 03:03 JsonSchema
drwxr-xr-x 2 root root 4096 Jan 24 12:29 OS
drwxr-xr-x 11 root root 4096 Jan 24 12:29 PEAR
-rw-r--r-- 1 root root 14825 Dec 10 02:54 pearcmd.php
-rw-r--r-- 1 root root 36171 Dec 10 02:54 PEAR.php
-rw-r--r-- 1 root root 1093 Dec 10 02:54 peclcmd.php
drwxr-xr-x 4 root root 4096 Nov 10 03:03 Psr
drwxr-xr-x 3 root root 4096 Nov 10 03:03 React
drwxr-xr-x 3 root root 4096 Nov 10 03:03 Seld
drwxr-xr-x 3 root root 4096 Jan 24 12:29 Structures
drwxr-xr-x 5 root root 4096 Nov 10 03:03 Symfony
-rw-r--r-- 1 root root 20694 Dec 10 02:54 System.php
drwxr-xr-x 2 root root 4096 Jan 24 12:29 XML

Why php8.2 permission denied?? (no replies)

$
0
0
I am facing issues on my website. When i post thai lottery result on my website then go to php then same issue appeared that php8.2 permission denied. Please help if anyone know about this

How to set root absolute include path in a php-fpm + nginx? (no replies)

$
0
0
I have the following files structure:

var ####################################
└── www ##############################
#####└── html ##########################
########## ├── include ##################
########## │######└── DB_tools.php ######
########## └── index.php ################

I want to put require_once('/include/DB_tools.php'); in index.php file so that it includes the DB_tools.php. Currently it gives me the following error:

Fatal error: Uncaught Error: Failed opening required '/include/DB_tools.php' (include_path='/var/www/html/') in /var/www/html/index.php:3 Stack trace: #0 {main} thrown in /var/www/html/index.php on line 3

default.conf:

server {
index index.php index.html;
server_name localhost;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /var/www/html;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php-fpm:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}

My question in Stackoverflow - https://stackoverflow.com/questions/76638623/how-to-configure-root-include-path-for-dockerized-php-with-nginx

NGINX FPM upgrade (no replies)

$
0
0
I am trying to upgrade roundcube from 1.4 (working) to 1.6.2. I am aware that I need to upgrade my PHP version before I upgrade.

Raspberry OS – Buster
NGINX


chew@mail:~ $ php -v
PHP 7.3.31-1~deb10u4 (cli) (built: Jun 19 2023 19:10:11) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.31, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.31-1~deb10u4, Copyright (c) 1999-2018, by Zend Technologies


Roundcube/installer
Checking PHP version
Version: OK(PHP 7.0.33-0+deb9u12 detected)

NGINX
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;

I have downloaded php7.3-fpm and it is running. When I change the nginx fastcgi to : fastcgi_pass unix:/run/php/php7.3-fpm.sock;

I get a HTTP 500 error when I open the roundcube URL.

What have I missed or what am doing wrong?

NGINX Error - recv() failed (104: Connection reset by peer) while reading response header from upstream (no replies)

$
0
0
Hi,
Getting following error on NGINX error logs. ANy help would be appreciated.

NGINX Error Logs:


9721 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: XXXXX, server:XXX.com, request: "OPTIONS /customer/categories?size=8 HTTP/1.1", upstream: "http://127.0.0.1:80/customer/categories?size=8", host: "XXX.com"
Viewing all 219 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>