Bonjour,

OS: Debian 10 Buster

APP: Nginx, php, mariadb, Monero

Sur mon serveur, j'ai un serveur de test (test.php) pour appeler sur mno node monero (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));`

Le script(via un appel curl) m'affiche 'true' quand monerod est OK (qu'il est syncroniser avec le reseau).

Mais mon probleme est le suivant, quand je lance l'application cli monero 'monerod', la page de test (test.php) me renvoie une erreur 404 nginx et impossible de voir d'autres informations sur la page.

Dans les logs nginx, J'ai ca :

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"

Ma configuration nginx du site web :

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

}
`

Et quand je ferme monerod (./monerod stop_daemon), la page 'test.php' redevient accessible et montre 'false', parceque monerod n'est plus syncroniser.

J'ai aussi essayer avec zcash et j'ai pas de probleme. je ne sais pas pourquoi. Cette erreur arrive peut importe le port utilise.

Comme solution possible, j'ai ajouter ces 3 lignes dans le bloc suivant : 'location ~ .php$' dans nginx. Mais ce la ne fonctionne pas, alors je les mises en commentaire :

fastcgi_read_timeout 600; fastcgi_send_timeout 600; fastcgi_connect_timeout 600;

Merci de l'aide

Edit:

Resultat de la requete curl sur terminal et non php :

`$ 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

Mon 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; } }`

Mon nginx accces.log : vide

Mon 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"

Ma configuration du site 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;`

Resultat de 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 -

Apres tout ca, la requete curl semble correcte, mais j'ai une mauvaise configuration de nginx et php...
Merci de votre aide

1 réponse


MA89
Auteur
Réponse acceptée

Bonjour,

@vadimfrost J'ai du mal cerner l'utilite de votre reponse.

Je vais donc vous poster ci-dessous la solution efficace :

A la fin de ce fichier :

/etc/nginx/snippets/fastcgi-php8.0.conf

Il convient d'ajouter ces lignes :

##
# FastCGI PHP connection
##  

fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
fastcgi_read_timeout 300;

##
# FastCGI Cache
## 

fastcgi_cache phpcache;
fastcgi_cache_valid 200 60m;
fastcgi_cache_methods GET HEAD;
add_header X-Fastcgi-Cache $upstream_cache_status;

cependant, ces lignes cause quelques problemes, il est possible de les resoudre en commentant ces lignes :

fastcgi_pass unix:/var/run/php/php8.0-fpm.sock; fastcgi_cache phpcache;

Cette solution efficace affiche donc la requete souhaitee et non plus l'erreur 404 de nginx comme avant.
Si vous avez des problemes, concernant cela, j'essayerai de vous aidai si possible.
Cordialement