How do I setup Gitea with a domain name or sub-domain?

November 16, 2019 233 views
Apache Nginx Ubuntu 18.04

Hey I’ve tried Apache and Nginx and can’t get either working with the image from the DigitalOcean Marketplace. So Here’s what I have:

  • Small VPS with Gitea on Ubuntu 18.04
  • Domain Name and Sub Domain’s DNS pointed to the VPS’s IP

I’ve tried:

  • Disabling UFW
  • Apache + Nginx (not at the same time)
  • I’m getting stuck setting up my domain name in either of those then keep deleting the droplet ^_^
1 comment
  • So… Apache vs Nginx for Gitea any advice? I remember from using GitLab that apache was a pain to setup so ended up caving n using nginx for ce n ci server.

    Here’s my failed steps for Apache

    sudo apt-get install apache2
    echo "ServerName localhost" >> /etc/apache2/apache2.conf
    cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/000-default.conf.bak
    cp /etc/apache2/sites-available/default-ssl.conf /etc/apache2/sites-available/default-ssl.conf.bak
    sudo a2dissite 000-default
    sudo touch /etc/apache2/sites-available/git.conf
    sudo a2ensite git
    sudo nano /etc/apache2/sites-available/git.conf
    

    Then I paste in this and restart apache

    <VirtualHost *:80>
        ServerName git.example.com
        ProxyPreserveHost On
        ProxyRequests off
        ProxyPass / http://localhost:3000/
        ProxyPassReverse / http://localhost:3000/
    </VirtualHost>
    

    I’ve tried changing Gitea’s port to 3000 and tried changing apache’s reverse to 80/443 and just can’t get it working ^_^

1 Answer

I finally figured it out in Apache!!! For anyone trying to get gitea running on Apache with a domain or subdomain, install apache:

sudo apt-get install apache2 -y

Next fix apache. There’s a localhost error that’s built into apache that drives me nuts… to fix it run:

echo "ServerName localhost" >> /etc/apache2/apache2.conf

Next fix apache for gitea. If you’re using a Gitea droplet apache will have thrown an error during install. This is ok, it’s just cuz its trying to initialize with a default setup on port 80 and Gitea is config’d to that port on DigitialOcean’s image. So to disable 000-default

sudo a2dissite 000-default.conf

Then there are 2 apache mods required, so to install those type:

sudo a2enmod proxy
sudo a2enmod proxy_http

Next create, enable, and edit a new conf file for apache:

sudo touch /etc/apache2/sites-available/gitea.conf
sudo a2ensite gitea
sudo nano /etc/apache2/sites-available/gitea.conf

Then add setup the reverse proxy

<VirtualHost *:80>
    ServerName git.example.com
    ProxyPreserveHost On
    ProxyRequests off
    ProxyPass / http://localhost:3000/
    ProxyPassReverse / http://localhost:3000/
</VirtualHost>

Finally restart apache (if you get an error about it already being stopped it’s cuz it never started because of the droplet error)

sudo service apache2 stop
sudo service apache2 start
systemctl status apache2.service
Have another answer? Share your knowledge.