Yet another way to work with Apache2 proxy


#1

Assumptions:

  • your valid domain: mydomain
  • your Gogs port: 8103
  • your desired public URL for Gogs: http://mydomain/gogs

Step 1: Edit <Your Gogs Root>/custom/conf/app.ini

[server]
DOMAIN = mydomain
HTTP_PORT = 8103
ROOT_URL = http://mydomain/gogs

Step 2: Edit /etc/apache2/mods-enabled/proxy.conf

# Gogs
ProxyPass           /gogs       http://localhost:8103
ProxyPassReverse    /gogs       http://localhost:8103
<Location /gogs>
    Require all granted
</Location>

Step 3: Restart apache2 and Gogs, and have a try with your browser!


Running app on subdir. HTTP 404 error
#2

Worth mentioning this can also be done in virtual hosts config too


#3

on step2 you need
ProxyPass /gogs http://localhost:8103/
ProxyPassReverse /gogs http://localhost:8103/


#4

With the trailing / as per your version, I get 404 on the login page. Only the home page will show.


#5

I find that the <Location> block is unnecessary.


#6

You should add

HTTP_ADDR = localhost

to prevent people bypassing Apache.