Here my server
section of /etc/gitea/app.ini
:
[server]
SSH_DOMAIN = example.com
DOMAIN = example.com
HTTP_PORT = 3000
ROOT_URL = http://example.com:3000
APP_DATA_PATH = /var/lib/gitea/data
DISABLE_SSH = false
SSH_PORT = 22
LFS_START_SERVER = true
LFS_JWT_SECRET = <secret>
OFFLINE_MODE = false
PROTOCOL = http
Browsing to http://example.com:3000 actually loads the Gitea page. Fine.
But if I change the ROOT_URL
to:
ROOT_URL = http://example.com:3000/mygit
it seems to run correctly:
May 05 14:16:49 vps gitea[513505]: 2024/05/05 14:16:49 cmd/web.go:304:listen() [I] Listen: http://0.0.0.0:3000/gitea
May 05 14:16:49 vps gitea[513505]: 2024/05/05 14:16:49 cmd/web.go:308:listen() [I] AppURL(ROOT_URL): http://example.com:3000/gitea/
May 05 14:16:49 vps gitea[513505]: 2024/05/05 14:16:49 cmd/web.go:311:listen() [I] LFS server enabled
May 05 14:16:49 vps gitea[513505]: 2024/05/05 14:16:49 ...s/graceful/server.go:70:NewServer() [I] Starting new Web server: tcp:0.0.0.0:3000 on PID: 513505
but now browsing to http://example.com:3000/gitea/ leads to the following error:
Failed to load asset files from http://example:3000/gitea/assets/js/index.js?v=1.21.11. Please make sure the asset files can be accessed.
I read the docs:
ROOT_URL: %(PROTOCOL)s://%(DOMAIN)s:%(HTTP_PORT)s/: Overwrite the automatically generated public URL. This is useful if the internal and the external URL don't match (e.g. in Docker).
I understand I can overwrite the generated URL in order to meet the desired one. I also read this question where one comment to the answer says:
changing the ROOT_URL should only affect links automatically generated by gitea. If you could connect to your installation via gitea.example.com it should still be the same - regardless the value of ROOT_URL
I don't understand what he means. My goal is to reach the gitea web page typing in my browser: http://example:3000/gitea.
I also read this issue, related to the asset error above, but the given solution is quite concise:
Please set your ROOT_URL in your app.ini correctly
How to set the parameters in order to fit my desired URL?
I had this same issue and was sad to see this question not answered. After some digging it looks like you and I both misunderstood how ROOT_URL is intended to be used.
The Gitea docs on reverse proxies say that your proxy needs to be configured to redirect your custom route to /. So for me with nginx that looks like:
...
location /mygit {
proxy_pass http://localhost:3000/
...
}
There doesn't appear to be a way to change the root url for gitea directly, only in conjunction with a reverse proxy.