How to setup ssl (HTTPS) on 1-click install Gitea droplet?

June 27, 2019 1.3k views
Git DigitalOcean Networking Let's Encrypt Ubuntu 18.04

I have a 1-click install droplet with Gitea, but it only works over HTTP how can I set it up to work over HTTPS?

3 Answers

I have figured out how to set it up (but I think it only works with domain names though…)
And don’t use the 1-click droplet, instead create a standard ubuntu 18.04 droplet
:

Initial updates & installs

apt-get update
apt-get upgrade
apt-get autoremove
apt-get install nginx

Set up users

adduser git
sudo usermod -aG sudo git

Folder structure setup

cd ~
sudo mkdir -p /var/lib/gitea/{custom,data,indexers,public,log}
sudo chown git:git /var/lib/gitea/{data,indexers,log}
sudo chmod 750 /var/lib/gitea/{data,indexers,log}
sudo mkdir /etc/gitea
sudo chown root:git /etc/gitea
sudo chmod 770 /etc/gitea

Nginx

sudo service nginx enable
sudo service nginx start
sudo service nginx status
sudo rm /etc/nginx/sites-enabled/default

Gitea installation

sudo wget -O gitea https://dl.gitea.io/gitea/1.8.3/gitea-1.8.3-linux-amd64
sudo chmod +x gitea
sudo cp gitea /usr/local/bin/gitea

ssl (Only for domain names)

sudo service nginx stop
sudo apt install certbot python-certbot-nginx
sudo certbot certonly --standalone -d [domain name]
sudo service nginx start
touch /etc/nginx/sites-available/git
sudo nano /etc/nginx/sites-available/git

Paste in this code and replace [YOUR-DOMAIN-HERE] with ex. example.com (your domain name)

*server {

listen 443 ssl;
servername [YOUR-DOMAIN-HERE];
ssl
certificate /etc/letsencrypt/live/[YOUR-DOMAIN-HERE]/fullchain.pem;
sslcertificatekey /etc/letsencrypt/live/[YOUR-DOMAIN-HERE]/privkey.pem;

location / {
    proxy_set_header  X-Real-IP  $remote_addr;
    proxy_pass http://localhost:3000;
}

}

Redirect HTTP requests to HTTPS

server {

listen 80;
servername [YOUR-DOMAIN-HERE];
return 301 https://$host$request
uri;
}
*

sudo ln -s /etc/nginx/sites-available/git /etc/nginx/sites-enabled
sudo service nginx restart

start gitea

sudo gitea web
  • @Buscedv I was able to use your steps to get it working on the 1-click app also. I just did the Nginx steps and updated my gitea installation to the latest.

    I have one question though… you mention that the ssl is only for domain names. What do you mean by that?

    Also, there is some weird formatting in one section above. I was able to figure out where the underscores where, but if you can still edit the post, it might be helpful to other people.

I have the same issue and the link above does not work. I tried everything from the official Gitea Docs but it simply does not work. Can anyone please provide some more details?

  • You can read my answer (the accepted solution)

    • Hello @Buscedv you are totally right, but I do not believe that your post should be not be marked as Answered. You have shown how to install Gitea on Ubuntu and install nginx as a server and addins SSL to nginx. That is a different question. The question was how to add SSL to the 1-click install offered by DO.

      You can definitely install Gitea on Ubuntu and I have already done that (a bit different than what you mentioned but still..) but the whole purpose of 1-click install is that you do not have to always do all of the steps above. Also, the 1-click install I believe does not use nginx. Not sure as there is no information on it.

      • Yeah I know but first of all, the 1-click droplet is outdated and second of all this was my own question and I found an answer.

        • Hello @Buscedv it is a good answer and I am happy you have found it. I am still hopeful that the 1-click install gets an update and some more details on how it is setup and how to add SSL to it :)

Hello,

There are a few ways to achive that, you could take a look at the Gitea official documentation on how to do this here:

https://docs.gitea.io/en-us/https-setup/

Let me know if something is not clear and I’ll be happy to help!

Regards,
Bobby

Have another answer? Share your knowledge.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!