OS: Debian 10 Buster
APP: Nginx, php, mariadb, Monero
On my host I have a test script (test.php) to call my daemon (http://127.0.0.1:18081/json_rpc):
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => 'http://127.0.0.1:18081/json_rpc',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => "{\"jsonrpc\":\"2.0\",\"id\":\"0\",\"method\":\"get_info\"}",
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_CONNECTTIMEOUT => 15,
CURLOPT_HTTP_VERSION =>CURL_HTTP_VERSION_2_0
]);
$result = json_decode(curl_exec($ch));
This script shows true when monerod is OK (correct launch and synchronized with network).
But my problem is that when I launch monerod (synchronized with network), the test script (test.php) returns a 404 nginx error page.
In the nginx log, I have this:
2021/07/10 12:15:01 [error] 7667#7667: *1 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 127.0.0.1, server: example.onion, request: "GET /test.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php8.0-fpm.sock", host: "example.onion"
My nginx website conf:
server {
listen 127.0.0.1:84;
server_name example.onion;
access_log off;
location @blackhole {
return 444;
}
root /var/www/html/;
index index.html index.php;
error_page 403 404 500 502 503 504 =444 @blackhole;
location ~ \.php$ {
include /etc/nginx/snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
}
}
And when I close monerod (./monerod stop_daemon), the page 'test.php' becomes accessible and show false, because monerod is not syncronized.
I also test with zcash and no problem. I don't know why. This error happens no matter which port is used (18081 or 18087).
As a possible solution I add these three lines to 'location ~ .php$' in nginx (as it says Nginx + Php-fpm fastcgi upstream timed out):
fastcgi_read_timeout 600;
fastcgi_send_timeout 600;
fastcgi_connect_timeout 600;
But it didn't work.
Thanks for help
Edit:
Result of curl on the command line:
$ curl -vd '{"jsonrpc":"2.0","id":"0","method":"get_info"}' http://localhost:18081
* Expire in 0 ms for 6 (transfer 0x55cb5266ffb0)
* Expire in 1 ms for 1 (transfer 0x55cb5266ffb0)
* Expire in 0 ms for 1 (transfer 0x55cb5266ffb0)
* Expire in 1 ms for 1 (transfer 0x55cb5266ffb0)
* Expire in 0 ms for 1 (transfer 0x55cb5266ffb0)
* Expire in 0 ms for 1 (transfer 0x55cb5266ffb0)
* Expire in 0 ms for 1 (transfer 0x55cb5266ffb0)
* Trying 127.0.0.1...
* TCP_NODELAY set
* Expire in 200 ms for 4 (transfer 0x55cb5266ffb0)
* Connected to localhost (127.0.0.1) port 18081 (#0)
> POST / HTTP/1.1
> Host: localhost:18081
> User-Agent: curl/7.64.0
> Accept: */*
> Content-Length: 46
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 46 out of 46 bytes
< HTTP/1.1 404 Not found
< Server: Epee-based
< Content-Length: 0
< Content-Type: text/plain
< Last-Modified: Fri, 23 Jul 2021 04:38:02 GMT
< Accept-Ranges: bytes
<
* Connection #0 to host localhost left intact
My nginx.conf :
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
server_tokens off;
server_names_hash_bucket_size 125;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}
My nginx accces.log : empty
My nginx error.log :
2021/07/23 04:32:13 [error] 540#540: *1 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 127.0.0.1, server: example.onion, request: "GET /test.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php8.0-fpm.sock", host: "example.onion"
2021/07/23 04:34:04 [error] 540#540: *3 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 127.0.0.1, server: example.onion, request: "GET /test.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php8.0-fpm.sock", host: "example.onion"
2021/07/23 05:16:40 [error] 540#540: *7 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 127.0.0.1, server: example.onion, request: "GET /test.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php8.0-fpm.sock", host: "example.onion"
2021/07/23 05:17:55 [error] 540#540: *9 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 127.0.0.1, server: example.onion, request: "GET /test.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php8.0-fpm.sock", host: "example.onion"
2021/07/23 05:20:38 [error] 540#540: *11 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 127.0.0.1, server: example.onion, request: "GET /test.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php8.0-fpm.sock", host: "example.onion"
2021/07/23 05:23:34 [error] 540#540: *13 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 127.0.0.1, server: example.onion, request: "GET /test.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php8.0-fpm.sock", host: "example.onion"
My website nginx conf :
server {
listen 127.0.0.1:88;
server_name example.onion;
access_log off;
location @blackhole {
return 444;
}
root /var/www/html/;
index index.html index.php;
error_page 403 404 500 502 503 504 =404 @blackhole;
location ~ \.php$ {
include /etc/nginx/snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
#fastcgi_read_timeout 600;
#fastcgi_send_timeout 600;
#fastcgi_connect_timeout 600;
}
}
fastcgi-php.conf :
# regex to split $uri to $fastcgi_script_name and $fastcgi_path
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
# Check that the PHP script exists before passing it
try_files $fastcgi_script_name =404;
# Bypass the fact that try_files resets $fastcgi_path_info
# see: http://trac.nginx.org/nginx/ticket/321
set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;
fastcgi_index index.php;
include fastcgi.conf;
Result of netstat -tlnp :
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:88 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:9050 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:90 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:18080 0.0.0.0:* LISTEN 787/./monerod
tcp 0 0 127.0.0.1:18081 0.0.0.0:* LISTEN 787/./monerod
tcp 0 0 127.0.0.1:18082 0.0.0.0:* LISTEN 787/./monerod
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN -
tcp6 0 0 :::22 :::* LISTEN -
curl -vd '{"jsonrpc":"2.0","id":"0","method":"get_info"}' http://localhost:18081/json_rpc
OK from the command line? If that works your PHP/nginx setup is the problem. If not, you're probably not synced properly./json_rpc
when running the command.