5

On my gitea server, I normally access it via ssh Local Port Forwarding; and it isn't accessible from the outside because I bind it to the localhost address.

I'm accessing it from http://127.0.0.1:8080 via "Local Port Forwarding", and it thinks that it's being accessed from http://127.0.0.1:3000; so certain features (the preview in the wiki and the issues for instance do not work (you can however save them, just not preview them); anyway it's mis-configured, see below, I'd like to change the Gitea Base URL so that anytime the server currently writes http://127.0.0.1:3000 it will write http://127.0.0.1:8080 instead (but that said, it would be good if it still operated off of port 3000):

gitea configuration

What line in gitea.ini changes this functionality? or is it more like a situation where I need to throw a reverse proxy in front of it that rewrites the URLs for me?

secustor
  • 3,001
  • 2
  • 14
  • 20
leeand00
  • 25,510
  • 39
  • 140
  • 297

1 Answers1

1

I did not struggle with port numbers but meant to change the domain (localhost to foo) and found ROOT_URL mentioned in the config cheat sheet:

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).

There is also a HTTP_PORT option which could apply to you as well.

See your /path/to/gitea/conf/app.ini -> [server] section and change accordingly

[server]
  APP_DATA_PATH    = /path/to/gitea
  DOMAIN           = localhost
  SSH_DOMAIN       = localhost
  HTTP_PORT        = 3000
  ROOT_URL         = http://localhost:3000/

I'd like to change the Gitea Base URL so that anytime the server currently writes http://127.0.0.1:3000 it will write http://127.0.0.1:8080 instead (but that said, it would be good if it still operated off of port 3000):

I assume setting ROOT_URL to http://127.0.0.1:8080 but leaving HTTP_PORT to default 3000 should do that.

nuala
  • 2,681
  • 4
  • 30
  • 50
  • Thanks for the suggestion. I changed the ROOT_URL but the web doesn't show anymore. Should I log in as "git" account? or is there anything to modify "app.ini" file? – Cloud Cho Jul 29 '23 at 00:34
  • @CloudCho 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 – nuala Aug 10 '23 at 20:46
  • thanks for the information. "installation via gitea.example.com"...would you share web link? I couldn't find in Google. – Cloud Cho Aug 10 '23 at 20:59
  • Sorry, I meant whatever URL you use to access your installation. Only you will know. I used a generic example. See https://example.com/ – nuala Aug 10 '23 at 22:01
  • thanks for extra explanation. By the way please, check the link...it looks like incorrect one. – Cloud Cho Aug 10 '23 at 22:11