Configure NGINX to listen on port 443

Discussion in 'Installation/Configuration' started by Gray Consulting, Mar 9, 2024.

  1. Gray Consulting

    Gray Consulting Member HowtoForge Supporter

    NGINX noob alert, sorry for the stupid questions!
    I'm running a new install of ISPConfig on Ubuntu 22.04 and NGINX. The first website I've configured works, but only HTTP. If I specify https://, it times out and reports 'unable to connect'.
    I'm pretty sure it's because in nginx.conf, there is no server{} section/directive at all. I know it listens on port 80 by default, so I need to add a directive for port 443.
    What I've found so far implies I need a server/domain name as part of the directive, e.g.:
    Code:
    server {
       listen 80;
       listen 8080;
       server_name example.com;
       location / {
           root /usr/share/nginx/html;
           index index.html index.htm;
    } }
    
    My question is, can I set up a directive as simple as this? Or will I need to assign a domain name for the server itself?
    Code:
    server {
        listen 80;
        listen 443;
    }
    
    Also, nginx.conf seems to be the only config file I care about, at least for this issue. Am I missing anything?

    Thanks as always!
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    No manual configuration change is required; the SSL section gets added automatically once the website has a valid SSL cert. Do not manually alter any Nginx config files if you do not want to break your setup. So all you have to do is enable the SSL checkbox of the website and the Let's Encrypt checkbox of the site to get an LE cert or add an SSL cert to the SSL tab of the website. If the Let's encrypt checkbox gets unticked after a minute, and no SSL section gets added, see Let's encrypt error faq post.
     
  3. till

    till Super Moderator Staff Member ISPConfig Developer

    And the configuration for websites is not in nginx.conf anyway, each website has its own config file in nginx sites-available folder which is activated by a symlink in sites-enabled folder.
     
  4. Gray Consulting

    Gray Consulting Member HowtoForge Supporter

    Thanks Till -
    Good save; was about to go where I shouldn't have. nginx.conf remains untouched.
    I am trying to add a (DigiCert) ssl certificate, but no luck so far. I've tried countless variations on installing; such as including the key and/or csr, etc. Right now I have only the cert and and bundle installed, which seems to be the standard config. ISPC confirmed ok.
    I can't find anything in logs, but may not be looking in the right place.
     
  5. till

    till Super Moderator Staff Member ISPConfig Developer

    Go to ssl tab of the website, copy the key into the key field, the cert into the cert field, and the bundle into the bundle field, select 'save certificate" as action, and press save. Its explained in detail in the ISPConfig manual as well.
     
  6. Gray Consulting

    Gray Consulting Member HowtoForge Supporter

    Once again, I have proved to be some form of idiot I was *sure* I tried that multiple times before, but apparently not. Cert & site now working.

    Thank you!!!
     
    till likes this.

Share This Page