search

Home  >  Q&A  >  body text

How to enable HTTPS for my VPS web server

<p>I purchased a VPS through Namecheap and its IP address is (example: 162.0.118.14). It's running on Ubuntu 18 and I can access it using putty or filezilla. </p> <p>Also, on my VPS, I host a website on port 3000 using Socket.io. So you can access my html file/website using http://162.0.118.14:3000. </p> <p>Meanwhile, I maintain a MySQL database on port 80 via apache2 for login/registration purposes, so I can access phpmyadmin using http://162.0.118.14/phpmyadmin. </p> <p>I also purchased a domain name from Namecheap (example: test.com). In its DNS records, I created a URL redirect record for host@ and set the value to http://162.0.118.14 (mask). This configuration redirects all traffic from the domain name to my web server. So now I can access my website using http://test.com (I redirect it to :3000 afterwards). </p> <p>However, currently I can only access the web server using http, but I want it to work using https. </p> <p>I searched and found many tutorials on how to purchase or generate a certificate to enable a web server to work with HTTPS. </p> <p>So now I'm wondering, do I need to buy a certificate or can I generate one myself for free to make HTTPS work? Also, how do I make it work with my VPS? </p>
P粉966335669P粉966335669473 days ago606

reply all(1)I'll reply

  • P粉251903163

    P粉2519031632023-08-14 09:05:38

    You can generate an SSL certificate for free using letsencrypt, or obtain it from cloudflare.

    If you are using nginx, you can find instructions on how to install the certificate in the documentation: http://nginx.org/en/docs/http/configuring_https_servers.html

    If you are using apache:

    <VirtualHost 162.0.118.14:443>
    DocumentRoot /var/www/
    SSL Engine on
    SSLCertificateFile /path/to/your_domain_name.crt
    SSLCertificateKeyFile /path/to/your_private.key
    SSLCertificateChainFile /path/to/cert.crt
    </VirtualHost>

    Please remember that the default port for https is 443. If your server is running on port 3000, you need to set up a reverse proxy to point port 443 to port 3000.

    nginx reverse proxy configuration: https://docs.nginx.com/nginx/admin-guide/web-server/reverse-proxy/

    reply
    0
  • Cancelreply