[GH-ISSUE #230] Error when Enable TLS #4554

Closed
opened 2026-03-01 15:34:12 +03:00 by kerem · 14 comments
Owner

Originally created by @sanvu88 on GitHub (Dec 8, 2023).
Original GitHub issue: https://github.com/0xJacky/nginx-ui/issues/230

Describe the bug

Nginx Configuration Parse Error when Enable TLS after Add Site

To Reproduce

Steps to reproduce the behavior:

  1. Manage Sites -> Add Site
  2. Fill the information then click Next -> Next
  3. Manage Sites -> Site List -> Modify site just added
  4. Click Enable TLS
  5. Click Encrypt website with Let's Encrypt -> Next

Screenshots

image

Info:

  • Server OS: Debian 12
  • Server Arch: x64
  • Nginx UI Version: 2.0.0-beta.6 (77)
  • Your Browser: Chrome

Additional context

  • If you enable TLS while adding a new site, you will not encounter this error. The error only occurs when TLS is enabled after the site has been added.
Originally created by @sanvu88 on GitHub (Dec 8, 2023). Original GitHub issue: https://github.com/0xJacky/nginx-ui/issues/230 **Describe the bug** Nginx Configuration Parse Error when Enable TLS after `Add Site` **To Reproduce** Steps to reproduce the behavior: 1. Manage Sites -> Add Site 2. Fill the information then click Next -> Next 3. Manage Sites -> Site List -> Modify site just added 4. Click Enable TLS 5. Click `Encrypt website with Let's Encrypt` -> Next **Screenshots** ![image](https://github.com/0xJacky/nginx-ui/assets/12091815/bab7df58-8a58-4658-9eb7-1bd42d979d72) **Info:** - Server OS: Debian 12 - Server Arch: x64 - Nginx UI Version: 2.0.0-beta.6 (77) - Your Browser: Chrome **Additional context** - If you enable TLS while adding a new site, you will not encounter this error. The error only occurs when TLS is enabled after the site has been added.
kerem 2026-03-01 15:34:12 +03:00
Author
Owner

@0xJacky commented on GitHub (Dec 10, 2023):

Which version of Nginx are you using?

I test on v1.24.0, it works fine.

<!-- gh-comment-id:1848844556 --> @0xJacky commented on GitHub (Dec 10, 2023): Which version of Nginx are you using? I test on v1.24.0, it works fine.
Author
Owner

@sanvu88 commented on GitHub (Dec 10, 2023):

Which version of Nginx are you using?

I test on v1.24.0, it works fine.

i use version nginx/1.25.3

<!-- gh-comment-id:1848852122 --> @sanvu88 commented on GitHub (Dec 10, 2023): > Which version of Nginx are you using? > > I test on v1.24.0, it works fine. i use version nginx/1.25.3
Author
Owner

@0xJacky commented on GitHub (Dec 10, 2023):

ok, i will test for this verison

<!-- gh-comment-id:1848856682 --> @0xJacky commented on GitHub (Dec 10, 2023): ok, i will test for this verison
Author
Owner

@0xJacky commented on GitHub (Dec 11, 2023):

I also test with the latest build of Nginx UI and nginx 1.25.3 but cannot reproduce this issue

<!-- gh-comment-id:1849328322 --> @0xJacky commented on GitHub (Dec 11, 2023): I also test with the latest build of Nginx UI and nginx 1.25.3 but cannot reproduce this issue
Author
Owner

@0xJacky commented on GitHub (Dec 11, 2023):

image

This config can pass nginx -t

<!-- gh-comment-id:1849355093 --> @0xJacky commented on GitHub (Dec 11, 2023): <img width="919" alt="image" src="https://github.com/0xJacky/nginx-ui/assets/13096985/6fbefdb8-73a0-4de6-91a3-13d440d96269"> This config can pass nginx -t
Author
Owner

@sanvu88 commented on GitHub (Dec 11, 2023):

Before configuring TLS, is your website enabled or disabled?

image

<!-- gh-comment-id:1849376314 --> @sanvu88 commented on GitHub (Dec 11, 2023): Before configuring TLS, is your website enabled or disabled? ![image](https://github.com/0xJacky/nginx-ui/assets/12091815/35fa662c-7e2e-4897-9c6c-f79848f3954c)
Author
Owner

@0xJacky commented on GitHub (Dec 11, 2023):

It is enabled. By the way, I used apt install nginx from offical mainline repo.

<!-- gh-comment-id:1849393957 --> @0xJacky commented on GitHub (Dec 11, 2023): It is enabled. By the way, I used apt install nginx from offical mainline repo.
Author
Owner

@sanvu88 commented on GitHub (Dec 11, 2023):

It is enabled. By the way, I used apt install nginx from offical mainline repo.

yeah, I use Nginx build from source. I will check again with apt

<!-- gh-comment-id:1849395059 --> @sanvu88 commented on GitHub (Dec 11, 2023): > It is enabled. By the way, I used apt install nginx from offical mainline repo. yeah, I use Nginx build from source. I will check again with apt
Author
Owner

@0xJacky commented on GitHub (Dec 11, 2023):

Maybe I should prepare the certificate at first by using http server, then create the https server from the configuration of http server.

<!-- gh-comment-id:1849402067 --> @0xJacky commented on GitHub (Dec 11, 2023): Maybe I should prepare the certificate at first by using http server, then create the https server from the configuration of http server.
Author
Owner

@sanvu88 commented on GitHub (Dec 11, 2023):

Maybe I should prepare the certificate at first by using http server, then create the https server from the configuration of http server.

I also think it's a good idea to sign SSL and make sure it's successful before creating an https server to avoid unnecessary errors.

<!-- gh-comment-id:1849406147 --> @sanvu88 commented on GitHub (Dec 11, 2023): > Maybe I should prepare the certificate at first by using http server, then create the https server from the configuration of http server. I also think it's a good idea to sign SSL and make sure it's successful before creating an https server to avoid unnecessary errors.
Author
Owner

@sanvu88 commented on GitHub (Dec 11, 2023):

humh, I tried testing with apt install nginx from official mainline repo. And still got the error. it's hard to understand

nginx: [emerg] no "ssl_certificate" is defined for the "listen ... ssl" directive in /etc/nginx/sites-enabled/example.org:17

Output of nginx -V:

nginx version: nginx/1.25.3
built by gcc 12.2.0 (Debian 12.2.0-14)
built with OpenSSL 3.0.9 30 May 2023 (running with OpenSSL 3.0.11 19 Sep 2023) 
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-http_v3_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-g -O2 -ffile-prefix-map=/data/builder/debuild/nginx-1.25.3/debian/debuild-base/nginx-1.25.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -Wl,--as-needed -pie'

virtual host:

server {
    listen 80;
    # listen [::]:80;
    server_name example.org;
    root /home/example.org;

    index index.html;

    location /.well-known/acme-challenge {
        proxy_set_header Host $host;
        proxy_set_header X-Real_IP $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr:$remote_port;
        proxy_pass http://127.0.0.1:9180;
    }
}

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

    server_name example.org;
    root /home/example.org;

    index index.html;

    location /.well-known/acme-challenge {
        proxy_set_header Host $host;
        proxy_set_header X-Real_IP $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr:$remote_port;
        proxy_pass http://127.0.0.1:9180;
    }
}

HTTP Context

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}

<!-- gh-comment-id:1849763686 --> @sanvu88 commented on GitHub (Dec 11, 2023): humh, I tried testing with apt install nginx from official mainline repo. And still got the error. it's hard to understand ```nginx: [emerg] no "ssl_certificate" is defined for the "listen ... ssl" directive in /etc/nginx/sites-enabled/example.org:17``` Output of `nginx -V`: ``` nginx version: nginx/1.25.3 built by gcc 12.2.0 (Debian 12.2.0-14) built with OpenSSL 3.0.9 30 May 2023 (running with OpenSSL 3.0.11 19 Sep 2023) TLS SNI support enabled configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-http_v3_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-g -O2 -ffile-prefix-map=/data/builder/debuild/nginx-1.25.3/debian/debuild-base/nginx-1.25.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -Wl,--as-needed -pie' ``` **virtual host:** ``` server { listen 80; # listen [::]:80; server_name example.org; root /home/example.org; index index.html; location /.well-known/acme-challenge { proxy_set_header Host $host; proxy_set_header X-Real_IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr:$remote_port; proxy_pass http://127.0.0.1:9180; } } server { listen 443 ssl; # listen [::]:443; http2 on; server_name example.org; root /home/example.org; index index.html; location /.well-known/acme-challenge { proxy_set_header Host $host; proxy_set_header X-Real_IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr:$remote_port; proxy_pass http://127.0.0.1:9180; } } ``` **HTTP Context** ``` http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; #gzip on; include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; } ```
Author
Owner

@0xJacky commented on GitHub (Dec 11, 2023):

Well, I found out the reason, this issue only occurs when this site is the only one enabled site. So, I have to change the processing order which is mention in https://github.com/0xJacky/nginx-ui/issues/230#issuecomment-1849402067.

<!-- gh-comment-id:1849817762 --> @0xJacky commented on GitHub (Dec 11, 2023): Well, I found out the reason, this issue only occurs when this site is the only one enabled site. So, I have to change the processing order which is mention in https://github.com/0xJacky/nginx-ui/issues/230#issuecomment-1849402067.
Author
Owner

@gaetan1903 commented on GitHub (Dec 13, 2023):

I have the same issue and i have only one site enabled

<!-- gh-comment-id:1853425761 --> @gaetan1903 commented on GitHub (Dec 13, 2023): I have the same issue and i have only one site enabled
Author
Owner

@sanvu88 commented on GitHub (Dec 13, 2023):

I have the same issue and i have only one site enabled

jacky fixed it here: github.com/0xJacky/nginx-ui@17d6216e36

<!-- gh-comment-id:1853540788 --> @sanvu88 commented on GitHub (Dec 13, 2023): > I have the same issue and i have only one site enabled jacky fixed it here: https://github.com/0xJacky/nginx-ui/commit/17d6216e364953abde5bae002a47c4311f3f3465
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/nginx-ui#4554
No description provided.