NGINX and Lets´s Encrypt fail

Infos:

  • Used Zammad version: newest
  • Used Zammad installation type: package
  • Operating system: Ubuntu 22.04
  • Browser + version: Chrome

If I use the command:

sudo certbot certonly --webroot -w /var/www/html -d support.*ZENSOR*.de --cert-path /path/to/ssl/certificate --key-path /path/to/ssl/certificate_key

then the error comes:

aving debug log to /var/log/letsencrypt/letsencrypt.log
Requesting a certificate for support.*ZENSOR*.de

Certbot failed to authenticate some domains (authenticator: webroot). The Certificate Authority reported these problems:
  Domain: support.*ZENSOR*.de
  Type:   connection
  Detail: *ZENSOR*: Fetching http://support.*ZENSOR*.de/.well-known/acme-challenge/obDuWniY576ruiUsZHPcNT6mnS0nyiJTb1AkQpr2yZA: Connection refused

Hint: The Certificate Authority failed to download the temporary challenge files created by Certbot. Ensure that the listed domains serve their content from the provided --webroot-path/-w and that files created there can be downloaded from the internet.

Some challenges have failed.
Ask for help or search for solutions at https://community.letsencrypt.org. See the logfile /var/log/letsencrypt/letsencrypt.log or re-run Certbot with -v for more details.

And if i want to start nginx there is this Error:

nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Mon 2023-06-26 18:00:18 UTC; 35s ago
       Docs: man:nginx(8)
    Process: 1809 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)
        CPU: 1ms

Jun 26 18:00:18 Zammad systemd[1]: Starting A high performance web server and a reverse proxy server...
Jun 26 18:00:18 Zammad nginx[1809]: nginx: [emerg] "server" directive is not allowed here in /etc/nginx/nginx.conf:1
Jun 26 18:00:18 Zammad nginx[1809]: nginx: configuration file /etc/nginx/nginx.conf test failed
Jun 26 18:00:18 Zammad systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE
Jun 26 18:00:18 Zammad systemd[1]: nginx.service: Failed with result 'exit-code'.
Jun 26 18:00:18 Zammad systemd[1]: Failed to start A high performance web server and a reverse proxy server.

The Configuration from NGINX is:

server {
    listen 80;
    zammad.*ZENSOR*.de;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl http2;
   zammad.*ZENSOR*.de;

    ssl_certificate /path/to/ssl/certificate;
    ssl_certificate_key /path/to/ssl/certificate_key;
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_ciphers 'TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384';

    access_log /var/log/nginx/zammad.access.log;
    error_log /var/log/nginx/zammad.error.log;

    client_max_body_size 50M;

    location /ws {
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_set_header CLIENT_IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_read_timeout 86400;
        proxy_pass http://zammad-websocket;
    }

    location / {
        proxy_set_header Host $http_host;
        proxy_set_header CLIENT_IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_read_timeout 300;
        proxy_pass http://zammad-railsserver;

I’ve already looked through the other threads and haven’t found one that fits. If I have missed one, just send the link.

Thanks in advance for any help

Hi @SoulTrapX, I didn’t have much time right now, therefore just a small hint:

In your NGINX configuration, in front of zammad.*ZENSOR*.de, server_name is missing.

In general, you should have a look in here: zammad/contrib/nginx/zammad_ssl.conf at stable · zammad/zammad · GitHub

Thanks for your time, I have now adjusted the config file, this now looks like this:

upstream zammad-railsserver {
  server 127.0.0.1:3000;
}

upstream zammad-websocket {
  server 127.0.0.1:6042;
}

server {
  listen 80;
  listen [::]:80;

  server_name support.*ZENSOR*.de;

  # security - prevent information disclosure about server version
  server_tokens off;

  access_log /var/log/nginx/zammad.access.log;
  error_log /var/log/nginx/zammad.error.log;

  location /.well-known/ {
    root /var/www/html;
  }

  return 301 https://$server_name$request_uri;

}


server {
  listen 443 ssl http2;
  listen [::]:443 ssl http2;

  server_name support.*ZENSOR.de;

  # security - prevent information disclosure about server version
  server_tokens off;

  ssl_certificate /etc/nginx/ssl/support.*ZENSOR*.pem;
  ssl_certificate_key /etc/nginx/ssl/support.*ZENSOR*.pem;

  ssl_protocols TLSv1.2;

  ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';

  ssl_dhparam /etc/nginx/ssl/dhparam.pem;

  ssl_prefer_server_ciphers on;

  ssl_session_cache shared:SSL:10m;
  ssl_session_timeout 180m;

  ssl_stapling on;
  ssl_stapling_verify on;

  ssl_trusted_certificate /etc/nginx/ssl/lets-encrypt-x3-cross-signed.pem;

  resolver 8.8.8.8 8.8.4.4;

  add_header Strict-Transport-Security "max-age=31536000" always;

  location = /robots.txt  {
    access_log off; log_not_found off;
  }

  location = /favicon.ico {
    access_log off; log_not_found off;
  }

  root /opt/zammad/public;

  access_log /var/log/nginx/zammad.access.log;
  error_log  /var/log/nginx/zammad.error.log;

  client_max_body_size 50M;

  location ~ ^/(assets/|robots.txt|humans.txt|favicon.ico|apple-touch-icon.png) {
    expires max;
  }

  # legacy web socket server
  location /ws {
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "Upgrade";
    proxy_set_header CLIENT_IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_read_timeout 86400;
    proxy_pass http://zammad-websocket;
  }

  # action cable
  location /cable {
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "Upgrade";
    proxy_set_header CLIENT_IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_read_timeout 86400;
    proxy_pass http://zammad-railsserver;
  }

  location / {
    proxy_set_header Host $http_host;
    proxy_set_header CLIENT_IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto	$scheme;

    # change this line in an SSO setup
    proxy_set_header X-Forwarded-User "";

    proxy_read_timeout 180;
    proxy_pass http://zammad-railsserver;

    gzip on;
    gzip_types text/plain text/xml text/css image/svg+xml application/javascript application/x-javascript application/json application/xml;
    gzip_proxied any;
  }
}

But now I still have this error:

nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Mon 2023-06-26 18:48:58 UTC; 5s ago
       Docs: man:nginx(8)
    Process: 1309 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)
        CPU: 1ms

Jun 26 18:48:58 Zammad systemd[1]: Starting A high performance web server and a reverse proxy server...
Jun 26 18:48:58 Zammad nginx[1309]: nginx: [emerg] "upstream" directive is not allowed here in /etc/nginx/nginx.conf:1
Jun 26 18:48:58 Zammad nginx[1309]: nginx: configuration file /etc/nginx/nginx.conf test failed
Jun 26 18:48:58 Zammad systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE
Jun 26 18:48:58 Zammad systemd[1]: nginx.service: Failed with result 'exit-code'.
Jun 26 18:48:58 Zammad systemd[1]: Failed to start A high performance web server and a reverse proxy server.

I guess you should read some nginx docs :slight_smile:

Btw: Your conf file for Zammad should be here: /etc/nginx/sites-available/zammad.conf

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