How to get HTTPS for Rust Web App
When I wrote the post How to deploy Rust Web App, I felt that I could help many Rustceans and others to inlcude Rust for web project and also get many reads comparing to other posts.
(You can find the latest contents at Steadylearner)
But I always felt that I should include the content for how to enable HTTPS for Rust Web Application with Nginx inside the post.
I spent some time to make HTTPS work but I couldn’t make it.
About a month have passed while I was learning Python to handle static files in my website.
Then, I was thinking of writing Rust posts again to share my working codes and knowledges as I planned before.
For that, I had to solve the problem of HTTPS first.
It was preventing for me to do other posts and I finally made it work and I could write this post.
This is a very short post for the major contents are already written in How to deploy Rust Web App.
(You may read code snippet part below only if you want to save your time.)
This is the last part of the series about deploying Rust Web Application.
(I want you to read the previous posts in the list below if you hadn’t also.)
- Showing static HTML, CSS, JS Files with Rust Rocket Route
- undefined route handling with Rocket and Tera
- How to include Single Page App in Rust Web Application
- Deploying Rust Web App at DigitalOcean
- How to get HTTPS for Rust Web App
Let’s start from the code. If you followed the previous posts, What you need is just two lines.
1. $sudo certbot --nginx # From official site
2. $sudo certbot renew --dry-run # From digitalocean
From the first process, you will see the process like these.
If you saw the messages like the ones above, You can visit your Rust Web Application and test the result as I did with Steadylearner.
I hope you made it.
You may have seen the message that your certificate will expire later and you have to do some process for that.
But we are prepared for it already with the first command we typed. You just need to verify it with
$sudo certbot renew --dry-run .
You can see that it is just simulating the renewal process in the description.
If there were no errors in the process, you don’t have to do nothing more.
We ended the entire process for deploying Rust Web App with this post.
(I found that reading the official documenation is very important while solving problems for this post.)
From now on, You are ready to make your own Rust backend website and deploy it with Nginx as I do with Steadylearner.
While I was practicing and developing Rust Web App, there were no easy examples to follow for deploying Rust Web Application.
It seemed impossible for me without them so I wanted to help others later with my own posts.
I decided to use Nginx for it is open source and you don’t have to follow the specific API given by some companies or service providers.
I am thinking of writing another series about JSON Webservice with Rust, CLI, database, template and integrating React Frontend in Rust Web Application with more details.
Thanks and please share this post with others.
- Did you like my coding style? Please, send messages via LinkedIn or Twitter. I am also the writer of React Package prop-passer you may read How To Write React Efficiently with Prop-Passer
- I am also developing www.steadylearner.com with Rust and React. I am spending time to prepare contents for it first.
I am not a native English speaker. When some words don’t make sense, grammar problems etc. Please leave a comment below. I will read this post again and edit them right away.