Erro 502 Gateway no Nginx?

RESOLVIDO: desativando o servidor nginx, executando discourse-setup, ativando o servidor nginx e recriando o aplicativo.

Olá. Estou tentando instalar o Discourse seguindo este guia.

Este é o meu app.yml editado (copiado das pastas do Discourse e editado seguindo os guias):

templates:
  - "templates/postgres.template.yml"
  - "templates/redis.template.yml"
  - "templates/web.template.yml"
  - "templates/web.ratelimited.template.yml"
  - "templates/web.socketed.template.yml"
## Descomente estas duas linhas se quiser adicionar o Lets Encrypt (https)
#  - "templates/web.ssl.template.yml"
#  - "templates/web.letsencrypt.ssl.template.yml"

## Quais portas TCP/IP este contêiner deve expor?
## Se você quiser que o Discourse compartilhe uma porta com outro servidor web como Apache ou nginx,
## veja https://meta.discourse.org/t/17247 para detalhes
expose:
#  - "80:80"   # http
#  - "2222:22"
#  - "443:443" # https

Este é o meu bloco nginx do discourse.conf:
server {

server_name forum.myhost;  #
listen [::]:443 ssl http2 ipv6only=on; # gerenciado pelo Certbot
listen 443 ssl http2; # gerenciado pelo Certbot
ssl_certificate /etc/letsencrypt/live/forum.myhost/fullchain.pem; # gerenciado pelo Certbot
ssl_certificate_key /etc/letsencrypt/live/forum.myhost/privkey.pem; # gerenciado pelo Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # gerenciado pelo Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # gerenciado pelo Certbot
ssl on;
http2_idle_timeout 5m; # aumentado do padrão de 3m;

location / {
    proxy_pass http://unix:/var/discourse/shared/standalone/nginx.http.sock;
    proxy_set_header Host $http_host;
    proxy_http_version 1.1;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto https;
    proxy_set_header X-Real-IP $remote_addr;
}
}
server {
if ($host = forum.myhost) {
    return 301 https://$host$request_uri;
} # gerenciado pelo Certbot

server_name www.forum.myhost;
return 301 $scheme://forum.myhost$request_uri;

    listen 80;
    listen [::]:80;

    server_name forum.myhost;
return 404; # gerenciado pelo Certbot
}

O servidor está funcionando com SSL (Certbot instalado) e redireciona http para https no domínio principal, mas o domínio do fórum exibe erro 502 Gateway. Estou usando o Cloudflare (sem opções de desempenho ou segurança ativadas).

Qualquer ajuda será muito apreciada. Não consigo executar o discourse-setup porque ele mostra “Google: "abrir portas SEU SERVIÇO NA NUVEM" para informações para resolver este problema.”

Também verifiquei o firewall.

EDIT: Talvez seja um problema com esta linha? (Não vejo este arquivo na pasta)
proxy_pass http://unix:/var/discourse/shared/standalone/nginx.http.sock;

1 curtida

Why are you using nginx as a proxy?

Are there other websites on this server?

2 curtidas

Yep Stephen, I’m using nginx and have plans to upload a Drupal site. Default domain is working with SSL as I commented, and forum subdomain shows 502 gateway error.

OK, I stopped nginx in my server and discourse-setup works but I now see this error message:

Enabling Let’s Encrypt
web.ssl.template.yml NOT ENABLED–was it on already?
letsencrypt.ssl.template.yml NOT ENABLED – was it on already?

Unfortunately, there was an error changing

-d This may happen if you have made unexpected changes.

I really don’t know if I need to use let’s encrypt from Discourse or outside if I have it installed in my server.

Thanks for reading.

LAST EDIT: I just start server nginx and primary and secondary domains are working (keeping server let’s encrypt from Certbot in Discourse instance)

2 curtidas

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.