Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Djbethel's avatar

Problems with Forge + SSL + Digital Ocean

Followed this article: https://medium.com/laravel-4/forge-ssl-66b4252db7d8

My site was working fine but after installing and activating the SSL certificate, I restarted the server and now my site doesn't show up at all.

No URI combination works. http. https. www. non-www Not sure what to do now. I'm using an SSL certificate from GoDaddy. Created my private key from there and also installed all of the Certs they gave me in a "bundle pack".

Should I have just installed only one certificate instead of all of them?

Any suggestions? Would really appreciate it

0 likes
28 replies
graham's avatar

Are you getting any error messages in your browser? Is there anything unusual in your log files on the server? Where did you generate the CSR?

bashy's avatar

Need to know the error message. If it's a connection refused it means your server isn't listening on port 443

Djbethel's avatar

Thanks for the responses.

@Graham My CSR was generated using Keychain Access. I've used this method before for other sites so I was comfortable knowing that it works.

@bashy Error code: ERR_CONNECTION_REFUSED

bashy's avatar

Yeah nothing to do with the certs. As of yet, they could be right or wrong.

For connection refused you need to check your Nginx config or settings via Forge as it's not got a virtual host that has listen 443 ssl; in. Is the site enabled in Nginx? /etc/nginx/sites-enabled should have a symlink to sites-available file.

Have you added a site for HTTPS? Not entirely sure how forge works as I don't use it. Here's an example of what they should look like https://bashy.im/blog/nginx-redirect-to-https-with-without-www-subdomain

Djbethel's avatar

If I post my nginx file here could that be useful to you?

Djbethel's avatar

And yes it is available in my sites-enabled.

I also notice when I type in mywebsite.com it tries to access http://www.mywebsite.com

However all versions of the URI give me the same error

1 like
Djbethel's avatar
server {
    listen 80;
    server_name mysite.com www.mysite.com;
    return 301 https://mysite.com$request_uri;
}

server {
    listen 443 ssl;
    server_name mysite.com www.mysite.com;
    root /home/forge/mysite.com/public;

    # FORGE SSL (DO NOT REMOVE!)
    ssl_certificate /etc/nginx/ssl/mysite.com/5772/server.crt;
    ssl_certificate_key /etc/nginx/ssl/mysite.com/5772/server.key;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

    index index.html index.htm index.php;

    charset utf-8;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
}
developeritsme's avatar

@Djbethel Try replacing your config with

server {
    listen 80;
    server_name mysite.com www.mysite.com;
    #return 301 https://mysite.com$request_uri;
    root /home/forge/mysite.com/public;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

    index index.html index.htm index.php;

    charset utf-8;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
}

server {
    listen 443 ssl;
    server_name mysite.com www.mysite.com;
    root /home/forge/mysite.com/public;

    # FORGE SSL (DO NOT REMOVE!)
    ssl_certificate /etc/nginx/ssl/mysite.com/5772/server.crt;
    ssl_certificate_key /etc/nginx/ssl/mysite.com/5772/server.key;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

    index index.html index.htm index.php;

    charset utf-8;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
}

Restart nginx and try to access http://mysite.com (w/o ssl)

Also, check the Network tab of the server and be sure that both ports (80 and 443) are in Active Firewall rules enabled from Any IP.

bashy's avatar

Well for one, this has a syntax error (no closing curly bracket)

location / {
        try_files $uri $uri/ /index.php?$query_string;

Should be

location / {
        try_files $uri $uri/ /index.php?$query_string;
}
2 likes
bashy's avatar

@Djbethel And you've made sure the vhost above is enabled? Would you like me to take a look?

fideloper's avatar

Y'all get this resolved?

@patton517, cPanel assumes CentOS (I believe only CentOS) as a distribution, while Forge uses Ubuntu explicitly, so I don't believe that's an option here.

AnthonyC's avatar

I'm having the same issue "This webpage is not available." "Reason: ERR_CONNECTION_REFUSED." New site installed on Forge, the non HTTPS is working but the HTTPS is giving me an error. Funny thing is, the http should redirect to https.

I've also restarted the server, restarted nginx etc. I would like to note I do have HHVM installed, not sure if that would cause the issue but I don't think it should.

Current nginx configuration:

server {
    listen 80;
    server_name my-site.com www.my-site.com;
    return 301 https://my-site.com$request_uri;
}

server {
    listen 443 ssl;
    server_name my-site.com www.my-site.com;
    root /home/forge/my-site.com/public;

    # FORGE SSL (DO NOT REMOVE!)
    ssl_certificate /etc/nginx/ssl/my-site.com/6257/server.crt;
    ssl_certificate_key /etc/nginx/ssl/my-site.com/6257/server.key;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

    index index.html index.htm index.php;

    charset utf-8;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

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

    access_log off;
    error_log  /var/log/nginx/my-site.com-error.log error;

    error_page 404 /index.php;

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root;
        include fastcgi_params;
    }

    location ~ /\.ht {
        deny all;
    }
}
bashy's avatar

@AnthonyC "ERR_CONNECTION_REFUSED" means the port isn't being listened on by anything. By the looks of it, those files aren't being executed.

Have a check in netstat for port 80 and 443. I normally just grep 'nginx' to check all.

sudo netstat -plnt | grep 'nginx'
AnthonyC's avatar

K, so for some reason nginx stopped and won't restart. It's failing and throwing this error into error log:

SSL_CTX_use_PrivateKey_file("/etc/nginx/ssl/my-site.com/6258/server.key") failed (SSL: error:0B080074:x509 certificate routines:X509_check_private_key:key values mismatch)
bashy's avatar

@AnthonyC Looks like the versions or values in the keys don't match. Do some searching for that error and you will see a few things you can try.

Djbethel's avatar

Sorry, I was away on business for a few days. Back now.

tarekadam's avatar

I had problems with forge + digitalocean + ssl. I had to remove the passphrase from my server.key file. openssl rsa -in server.key -out server.key

Note that you will need the original passphrase, and once you're done you'll have to start nginx because it is most likely not even running.

doublel's avatar

we fixed it by making a chained certificate as explained here http://nginx.org/en/docs/http/configuring_https_servers.html

$ cat www.example.com.crt bundle.crt > www.example.com.chained.crt The resulting file should be used in the ssl_certificate directive:

server { listen 443 ssl; server_name www.example.com; ssl_certificate www.example.com.chained.crt; ssl_certificate_key www.example.com.key; ... }

Please or to participate in this conversation.