I just bought a domain and am trying to set up HTTPS redirection on my R Plumber API. I made sure that the droplet IP is pointing to the domain and checked that it works. So currently I can access the plumber API over HTTP. I have an SSL Certificate on DO with my domain name. I tried using a Load Balancer but that didn’t work. Any guidance for how I would proceed?

I also tried using the “doconnecthttps” function from the plumberDeploy package, but I keep getting the error “Error: Authentication with ssh server failed”

I would be happy to provide any more details if needed. Thank you in advance

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
1 answer

Hi,
If you deployed your R Plumber API with plumberDeploy package, then you have nginx installed and configured as reverse proxy for your R Plumber API. The only things you have to do are:

  • configure nginx server block to use SSL certificate
  • open port TCP 443 in firewall for https connections.

Questions:

1. What address and port does the R API listen on ? Execute the command:

sudo netstat -tulpn | grep R

2. How do you access R API in a browser ? I mean, what do you type in an address bar of a browser to get your API (e.g. http://mydomain.com/RAPI) ?

3. Do you know where you have your SSL certificate files stored ? You need to know it to configure nginx server block.

4. You probably use ufw to configure a firewall. Check if ufw is active and the port TCP 443 is listed:

sudo ufw status

5. Do you have DO Cloud Firewall active and configured for your droplet ? Check in DO control panel - Networking - Firewalls - configured firewall (if any) - Droplets.

    1. The address is 0.0.0.0 port=8000

    2. The domain is http://inquire-plumber-r.com:8000/

    3. Where can I obtain an SSL Certificate

    4-5. How would I do those?

    Thank you for you help. It is very much appreciated.

    • 1, 2. So, your R API is accessible directly from the internet. We will change this access. However, I am pretty sure that you have an alternative access already configured by plumberDeploy, with nginx as reverse proxy. Can you provide a result for this command:

      sudo ls -la /etc/nginx/sites-available/plumber-apis/
      

      3. You mentioned you already have a certificate for your domain. Can you see it in DigitalOcean control panel ? You can find out more here on managing certificates in DO. But, if you actually do not have a certificate, you can obtain it from Let’s Encrypt using certbot on your droplet.

      4. Just execute the command and check if it gives any result. If you get any info, note what is the ufw status (active/inactive), what ports are listed, and if port 443/tcp is on that list.

      5. Log in to DigitalOcean control panel and navigate to Networking, and then Firewalls. Check if you have any firewall on the list. If there is any, click on it and then on Droplets to check if your droplet (with R plumber API) is on the list. Here is the doc on this subject.

Submit an Answer