AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • Início
  • system&network
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • Início
  • system&network
    • Recentes
    • Highest score
    • tags
  • Ubuntu
    • Recentes
    • Highest score
    • tags
  • Unix
    • Recentes
    • tags
  • DBA
    • Recentes
    • tags
  • Computer
    • Recentes
    • tags
  • Coding
    • Recentes
    • tags
Início / server / Perguntas / 946614
Accepted
Daniel
Daniel
Asked: 2018-12-26 17:19:59 +0800 CST2018-12-26 17:19:59 +0800 CST 2018-12-26 17:19:59 +0800 CST

502 gateway ruim por causa do índice indefinido?

  • 772

No meu site, recebo um gateway ruim 502 após implementar a seguinte configuração:

# Default server configuration
  2 #
  3  server {
  4         listen 80;
  5         listen [::]:80;
  6         server_name microurb.club;
  7         return 301 http://www.microurb.club;
  8  }
  9
 10  server {
 11         listen 80;
 12         listen [::]:80;
 13
 14   # SSL configuration
 15   #
 16   # listen 443 ssl default_server;
 17   # listen [::]:443 ssl default_server;
 18   #
 19   # include snippets/snakeoil.conf;
 20
 21   root /var/www/microurb.com/public_html;
 22
 23   # Add index.php to the list if you are using PHP
 24  index index.php index.html index.htm index.nginx-debian.htm;
 25
 26  server_name  www.microurb.club;
 27 ·
 28  include global/restrictions.conf;
 29  include global/wordpress.conf;
 30 ·
 31 # location / {
 32 #   # First attempt to serve request as file, then
 33 #   # as directory, then fall back to displaying a 404.
 34 #   try_files $uri $uri/ =404;
 35 # }
 36
 37   location ~ \.php$ {
 38     include snippets/fastcgi-php.conf;
 39     fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
 40   }
 41
 42   # Allow access to the ACME Challenge directory
 43       location ~ /\.well-known\/acme-challenge {
 44         allow all;
 45   }
 46
 47   include custom_config_files/x_protection.conf;
 48 }
 49
 50 server {

 51         listen 443 ssl http2;
 52         listen [::]:443 ssl http2;
 53         server_name microurb.club;
 54         return 301 https://www.microurb.club;
 55         include ssl/ssl_general.conf;
 56         include ssl/ssl_microurb.com.conf;
 57 }
 58
 59 server {
 60         listen 443 ssl http2;
 61         listen [::]:443 ssl http2;
 62         server_name www.microurb.club;
 63
 64         include ssl/ssl_general.conf;
 65         include ssl/ssl_microurb.com.conf;
 66
 67         root /var/www/microurb.com/public_html;
 68
 69         # Add index.php to the list if you are using PHP
 70         index index.html index.php;
 71
 72         location ~ \.php$ {
 73           include snippets/fastcgi-php.conf;
 74           fastcgi_pass unix:/var/run/php7.0-fpm.sock;
 75         }
 76
 77         include custom_config_files/x_protection.conf;
 78 }
 79

Eu fiz um:

sudo tail -30 /var/log/nginx/error.log

E recebi os seguintes erros, mas não sei o que significam:

PHP message: PHP Notice:  Undefined index: success in /var/www/microurb.com/public_html/index.php on line 295" while reading upstream, client: 24.55.9.54, server: www.microurb.club, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "www.microurb.club"
2018/12/25 20:07:05 [crit] 18408#18408: *40 connect() to unix:/var/run/php7.0-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 24.55.9.54, server: www.microurb.club, request: "GET / HTTP/2.0", upstream: "fastcgi://unix:/var/run/php7.0-fpm.sock:", host: "www.microurb.club"
2018/12/25 20:07:06 [error] 18408#18408: *40 open() "/var/www/microurb.com/public_html/favicon.ico" failed (2: No such file or directory), client: 24.55.9.54, server: www.microurb.club, request: "GET /favicon.ico HTTP/2.0", host: "www.microurb.club", referrer: "https://www.microurb.club/"
2018/12/25 20:07:10 [crit] 18408#18408: *40 connect() to unix:/var/run/php7.0-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 24.55.9.54, server: www.microurb.club, request: "GET / HTTP/2.0", upstream: "fastcgi://unix:/var/run/php7.0-fpm.sock:", host: "www.microurb.club"
2018/12/25 20:07:20 [crit] 18408#18408: *40 connect() to unix:/var/run/php7.0-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 24.55.9.54, server: www.microurb.club, request: "GET / HTTP/2.0", upstream: "fastcgi://unix:/var/run/php7.0-fpm.sock:", host: "www.microurb.club"

Acredito que o problema tenha raiz na minha configuração acima, mas não tenho certeza de onde. Quando tento descomentar este bloco:

 31 # location / {
 32 #   # First attempt to serve request as file, then
 33 #   # as directory, then fall back to displaying a 404.
 34 #   try_files $uri $uri/ =404;
 35 # }

Recebo um erro depois de executar sudo nginx -tdizendo que tenho nginx: [emerg] duplicate location "/" in /etc/nginx/sites-enabled/microurb.com:31, mas só tenho um. Não tenho certeza por que recebo esse erro.

nginx
  • 1 1 respostas
  • 318 Views

1 respostas

  • Voted
  1. Best Answer
    kolbyjack
    2018-12-27T08:40:27+08:002018-12-27T08:40:27+08:00

    Seus caminhos fastcgi_pass nas linhas 39 e 74 não correspondem (74 está faltando um /php). Como está reclamando do caminho na linha 74, altere isso para corresponder à linha 39:

    fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
    
    • 1

relate perguntas

Sidebar

Stats

  • Perguntas 205573
  • respostas 270741
  • best respostas 135370
  • utilizador 68524
  • Highest score
  • respostas
  • Marko Smith

    Você pode passar usuário/passar para autenticação básica HTTP em parâmetros de URL?

    • 5 respostas
  • Marko Smith

    Ping uma porta específica

    • 18 respostas
  • Marko Smith

    Verifique se a porta está aberta ou fechada em um servidor Linux?

    • 7 respostas
  • Marko Smith

    Como automatizar o login SSH com senha?

    • 10 respostas
  • Marko Smith

    Como posso dizer ao Git para Windows onde encontrar minha chave RSA privada?

    • 30 respostas
  • Marko Smith

    Qual é o nome de usuário/senha de superusuário padrão para postgres após uma nova instalação?

    • 5 respostas
  • Marko Smith

    Qual porta o SFTP usa?

    • 6 respostas
  • Marko Smith

    Linha de comando para listar usuários em um grupo do Windows Active Directory?

    • 9 respostas
  • Marko Smith

    O que é um arquivo Pem e como ele difere de outros formatos de arquivo de chave gerada pelo OpenSSL?

    • 3 respostas
  • Marko Smith

    Como determinar se uma variável bash está vazia?

    • 15 respostas
  • Martin Hope
    Davie Ping uma porta específica 2009-10-09 01:57:50 +0800 CST
  • Martin Hope
    kernel O scp pode copiar diretórios recursivamente? 2011-04-29 20:24:45 +0800 CST
  • Martin Hope
    Robert ssh retorna "Proprietário incorreto ou permissões em ~/.ssh/config" 2011-03-30 10:15:48 +0800 CST
  • Martin Hope
    Eonil Como automatizar o login SSH com senha? 2011-03-02 03:07:12 +0800 CST
  • Martin Hope
    gunwin Como lidar com um servidor comprometido? 2011-01-03 13:31:27 +0800 CST
  • Martin Hope
    Tom Feiner Como posso classificar a saída du -h por tamanho 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich O que é um arquivo Pem e como ele difere de outros formatos de arquivo de chave gerada pelo OpenSSL? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent Como determinar se uma variável bash está vazia? 2009-05-13 09:54:48 +0800 CST

Hot tag

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • Início
  • Perguntas
    • Recentes
    • Highest score
  • tag
  • help

Footer

AskOverflow.Dev

About Us

  • About Us
  • Contact Us

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve