An error occurs when building Discourse over HTTP

AI-generated summary

The user encountered an error while building Discourse over HTTP, where Nginx attempted to load an SSL certificate despite the setup using an ALB with SSL termination. ramamang had configured the app.yml to use HTTP only and expected Nginx to avoid SSL, but the error persisted. MihirR explained that the issue was due to leftover SSL configuration in Nginx, advising to ensure the app.yml had no SSL templates, rebuild the app, and remove any SSL-related directives (like ssl_certificate) in the Nginx config. After applying these changes, ramamang confirmed the issue was resolved.

  1. Domain configuration completed
  2. AWS EC2 instance created
  3. Certificate issued using ACM
  4. Configured 443 and connected the certificate via ALB
  5. ALB routes domain traffic to the EC2 instance on port 80

Before building Discourse, I modified the app.yml file to configure HTTP connections:

templates:
  - "templates/postgres.template.yml"
  - "templates/redis.template.yml"
  - "templates/web.template.yml"
  ## Uncomment the next line to enable the IPv6 listener
  #- "templates/web.ipv6.template.yml"
  - "templates/web.ratelimited.template.yml"
  ## Uncomment these two lines if you wish to add Lets Encrypt (https)
  #- "templates/web.ssl.template.yml"
  #- "templates/web.letsencrypt.ssl.template.yml"

## which TCP/IP ports should this container expose?
## If you want Discourse to share a port with another webserver like Apache or nginx,
## see https://meta.discourse.org/t/17247 for details
expose:
  - "80:80"   # http
 #- "443:443" # https

After making the changes, I built Discourse and checked the configuration, but nginx keeps requesting an SSL key with the following error:

[emerg] 7416#7416: cannot load certificate "/shared/ssl/discourse.xxxxxxx.com.cer": PEM_read_bio_X509_AUX() failed (SSL: error:0480006C:PEM routines::no start line:Expecting: TRUSTED CERTIFICATE)

Is there a way to prevent nginx from attempting to load the key or to make nginx work properly over HTTP?

The error happens because Nginx is still looking for an SSL certificate, but your ALB is handling the SSL. Here’s how to fix it:

  1. Check your app.yml: It looks like you’ve already disabled SSL templates, so you can skip this.

  2. Rebuild Discourse: Run ./launcher rebuild app to apply the changes.

  3. Check Nginx settings: Inside the container, look at the Nginx config and make sure there are no SSL lines (ssl_certificate, ssl_certificate_key). If you find any, remove them and restart Nginx with sv restart nginx.

  4. Verify your ALB setup: Make sure your ALB is terminating SSL on port 443 and forwarding HTTP (port 80) to your EC2.

That should stop Nginx from looking for the SSL certificate, and everything should work fine over HTTP!

Thank you. I resolved the issue based on the related content and other feedback.