I cant install certbot ssl certificate on vps

Please fill out the fields below so we can help you better. Note: you must provide your domain name to get help. Domain names for issued certificates are all made public in Certificate Transparency logs (e.g. https://crt.sh/?q=example.com), so withholding your domain name here does not increase secrecy, but only makes it harder for us to provide help.

My domain is:megaleio.co.za

I ran this command: sudo certbot --nginx -d megaleio.co.za -d www.megaleio.co.za

It produced this output: Saving debug log to /var/log/letsencrypt/letsencrypt.log

Error while running nginx -c /etc/nginx/nginx.conf -t.

nginx: [emerg] no "ssl_certificate" is defined for the "listen ... ssl" directive in /etc/nginx/conf.d/megaleio.conf:17

nginx: configuration file /etc/nginx/nginx.conf test failed

The nginx plugin is not working; there may be problems with your existing configuration.

The error was: MisconfigurationError('Error while running nginx -c /etc/nginx/nginx.conf -t.\n\nnginx: [emerg] no "ssl_certificate" is defined for the "listen ... ssl" directive in /etc/nginx/conf.d/megaleio.conf:17\nnginx: configuration file /etc/nginx/nginx.conf test failed\n')

My web server is (include version): nginx version: nginx/1.20.1

The operating system my web server runs on is (include version):
NAME="AlmaLinux"

VERSION="9.5 (Teal Serval)"

ID="almalinux"

ID_LIKE="rhel centos fedora"

VERSION_ID="9.5"

PLATFORM_ID="platform:el9"

PRETTY_NAME="AlmaLinux 9.5 (Teal Serval)"

ANSI_COLOR="0;34"

LOGO="fedora-logo-icon"

CPE_NAME="cpe:/o:almalinux:almalinux:9::baseos"

HOME_URL="https://almalinux.org/"

DOCUMENTATION_URL="https://wiki.almalinux.org/"

BUG_REPORT_URL="https://bugs.almalinux.org/"

ALMALINUX_MANTISBT_PROJECT="AlmaLinux-9"

ALMALINUX_MANTISBT_PROJECT_VERSION="9.5"

REDHAT_SUPPORT_PRODUCT="AlmaLinux"

REDHAT_SUPPORT_PRODUCT_VERSION="9.5"

SUPPORT_END=2032-06-01

My hosting provider, if applicable, is: domains.co.za

I can login to a root shell on my machine (yes or no, or I don't know):

I'm using a control panel to manage my site (no, or provide the name and version of the control panel):

The version of my client is (e.g. output of certbot --version or certbot-auto --version if you're using Certbot) : certbot 2.11.0

It's complaining about this. What's in that file?

1 Like

the file has two server blocks: one for redirecting HTTP to HTTPS and another that serves a frontend app while proxying API requests to a backend. The frontend files are stored in /var/www/my-app/build, and API requests are forwarded to localhost:5000."

i hard coded the file

Please show the output of sudo nginx -T that is a capital T

2 Likes

Hi, this is what i got ,

sudo nginx -T

nginx: [emerg] unknown directive "

server" in /etc/nginx/conf.d/megaleio.conf:4

nginx: configuration file /etc/nginx/nginx.conf test failed

Please fix your nginx first before trying to get a cert using Certbot.

You currently have a LiteSpeed server responding to HTTP requests on port 80. How do you plan to have that working with nginx?

Request to: www.megaleio.co.za/41.222.32.13, Result: [Address=41.222.32.13,Address Type=IPv4,Server=LiteSpeed

1 Like

nginx: [warn] conflicting server name "example.com" on 0.0.0.0:80, ignored
nginx: [warn] conflicting server name "www.example.com" on 0.0.0.0:80, ignored
nginx: [warn] conflicting server name "api.example.com" on 0.0.0.0:80, ignored

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

configuration file /etc/nginx/nginx.conf:
Main nginx configuration file

To be completely transparent, I am not entirely sure about the best approach to have LiteSpeed and Nginx work together seamlessly. However, I was hoping to understand that currently, LiteSpeed is handling HTTP requests on port 80. The plan I had in mind is to configure Nginx to handle the traffic while ensuring compatibility with LiteSpeed. Specifically, we would set up Nginx as a reverse proxy server for handling incoming requests, while LiteSpeed can continue managing traffic as needed for specific use cases.

Please let me know if i should provide additional info

You need to decide that before getting certs. Whichever system will "see" the HTTPS request on port 443 first is the one that needs the cert. And, is usually the best one to use to get your cert.

Proxying from that to something else on your local network (or same machine) is often done with HTTP (not HTTPS) so does not need a cert.

1 Like