Migrated GITEA to new domain - HTTPS and SSH point to old one #7320

Closed
opened 2025-11-02 07:22:52 -06:00 by GiteaMirror · 7 comments
Owner

Originally created by @kdamianakis on GitHub (May 10, 2021).

  • Gitea version (or commit ref): 1.14.0+dev-662-g32c4563d8
  • Operating system: Ubuntu 20

Gitea has been installed via docker compose and runs behind an NGINX proxy. I have migrated the GITEA from one domain to another by copying/restoring the database and the binded volume containing the data. The database and the data and all of the settings appear ok on the new domain. NGINX proxy, etc all seem to work.

On the site settings I can see the old domain name even with the docker-compose ROOT_URL and DOMAIN pointing to new values. I assume that somewhere in the database and the old-copied data from the previous domain via the volume there is a setting that would need to be changed as the new values from docker-compose do not seem to hold for current or new projects in the GITEA.

Any advice appreciated.

  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
  • Log gist:
Originally created by @kdamianakis on GitHub (May 10, 2021). <!-- NOTE: If your issue is a security concern, please send an email to security@gitea.io instead of opening a public issue --> <!-- 1. Please speak English, this is the language all maintainers can speak and write. 2. Please ask questions or configuration/deploy problems on our Discord server (https://discord.gg/gitea) or forum (https://discourse.gitea.io). 3. Please take a moment to check that your issue doesn't already exist. 4. Make sure it's not mentioned in the FAQ (https://docs.gitea.io/en-us/faq) 5. Please give all relevant information below for bug reports, because incomplete details will be handled as an invalid report. --> - Gitea version (or commit ref): 1.14.0+dev-662-g32c4563d8 - Operating system: Ubuntu 20 Gitea has been installed via docker compose and runs behind an NGINX proxy. I have migrated the GITEA from one domain to another by copying/restoring the database and the binded volume containing the data. The database and the data and all of the settings appear ok on the new domain. NGINX proxy, etc all seem to work. On the site settings I can see the old domain name even with the docker-compose ROOT_URL and DOMAIN pointing to new values. I assume that somewhere in the database and the old-copied data from the previous domain via the volume there is a setting that would need to be changed as the new values from docker-compose do not seem to hold for current or new projects in the GITEA. Any advice appreciated. <!-- Please also tell us how you are running gitea, e.g. if it is being run from docker, a command-line, systemd etc. ---> <!-- If you are using a package or systemd tell us what distribution you are using --> - Database (use `[x]`): - [ ] PostgreSQL - [x] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [ ] No - Log gist: <!-- It really is important to provide pertinent logs --> <!-- Please read https://docs.gitea.io/en-us/logging-configuration/#debugging-problems --> <!-- In addition, if your problem relates to git commands set `RUN_MODE=dev` at the top of app.ini -->
Author
Owner

@zeripath commented on GitHub (May 10, 2021):

What do you mean "site settings"?

Are you sure that you have definitely restarted Gitea since the settings have been set and that the underlying app.ini file has been changed?

How did you change/set these values in the docker compose? Are you using the GITEA__server__ROOT_URL environment variable or some other way?

@zeripath commented on GitHub (May 10, 2021): What do you mean "site settings"? Are you sure that you have definitely restarted Gitea since the settings have been set and that the underlying app.ini file has been changed? How did you change/set these values in the docker compose? Are you using the `GITEA__server__ROOT_URL` environment variable or some other way?
Author
Owner

@kdamianakis commented on GitHub (May 10, 2021):

I mean the site settings of the Gitea - after the restoration to the VM that is running on a New Domain Name (Domain B) it is running happily that Domain A but all of the HTTPS and SSH DOMAINs restored repositories and organizations point to the old domain (Domain A). I am trying to see how to change that. I have restarted many times the docker-compose and changed the ENV variables to match the new ROOT_URL and DOMAIN settings for Domain B but it does not seem to pick them up. I am in the process of manually setting the app.ini settings within the docker container for the Gitea - so far its now working but hopefully there is something that I have missed that can be found. Site Settings are the settings that are under Site Administration -> Configuration -> Server Configuration. I was hoping that it picks them up from the ENV on docker-compose or the app.ini but they may be in the database..?

@kdamianakis commented on GitHub (May 10, 2021): I mean the site settings of the Gitea - after the restoration to the VM that is running on a New Domain Name (Domain B) it is running happily that Domain A but all of the HTTPS and SSH DOMAINs restored repositories and organizations point to the old domain (Domain A). I am trying to see how to change that. I have restarted many times the docker-compose and changed the ENV variables to match the new ROOT_URL and DOMAIN settings for Domain B but it does not seem to pick them up. I am in the process of manually setting the app.ini settings within the docker container for the Gitea - so far its now working but hopefully there is something that I have missed that can be found. Site Settings are the settings that are under Site Administration -> Configuration -> Server Configuration. I was hoping that it picks them up from the ENV on docker-compose or the app.ini but they may be in the database..?
Author
Owner

@techknowlogick commented on GitHub (May 10, 2021):

Which specific env vars are you using? If they don't start with GITEA__ then those have been deprecated in lieu of using the env-to-ini tool, and the deprecated env vars have only ever been used to initialize config, so if app.ini already existed then it wouldn't be updated (hence move to use env-to-ini tool which handles that).

@techknowlogick commented on GitHub (May 10, 2021): Which specific env vars are you using? If they don't start with `GITEA__` then those have been deprecated in lieu of using the env-to-ini tool, and the deprecated env vars have only ever been used to initialize config, so if app.ini already existed then it wouldn't be updated (hence move to use env-to-ini tool which handles that).
Author
Owner

@kdamianakis commented on GitHub (May 10, 2021):

Thank you for this - I was using the non GITEA_ ones and have now changed the docker_compose with
environment:
- GITEA_VIRTUAL_PORT=3000
- GITEA_VIRTUAL_HOST=project.com
- GITEA_DISABLE_REGISTRATION=true
- GITEA_ROOT_URL=https://project.com/gitea/
- GITEA_DOMAIN=project.com
but its still not working. I have now manually changed the api.ini and restart. This seems to have worked. I shall test it some more.

@kdamianakis commented on GitHub (May 10, 2021): Thank you for this - I was using the non GITEA_ ones and have now changed the docker_compose with environment: - GITEA_VIRTUAL_PORT=3000 - GITEA_VIRTUAL_HOST=project.com - GITEA_DISABLE_REGISTRATION=true - GITEA_ROOT_URL=https://project.com/gitea/ - GITEA_DOMAIN=project.com but its still not working. I have now manually changed the api.ini and restart. This seems to have worked. I shall test it some more.
Author
Owner

@zeripath commented on GitHub (May 10, 2021):

Thank you for this - I was using the non GITEA_ ones and have now changed the docker_compose with
environment:

You've done these conversions incorrectly, see https://docs.gitea.io/en-us/install-with-docker/#managing-deployments-with-environment-variables

  • GITEA_VIRTUAL_PORT=3000

(I'm not sure where this comes from ... it wasn't in release/v1.13 or 1.14 or main) The closest equivalent is:

GITEA__server__HTTP_PORT=3000

but you may want to put it back to VIRTUAL_PORT=3000 and add the above too.

  • GITEA_VIRTUAL_HOST=project.com

This one I'm really not sure about, nearest is DOMAIN:

GITEA__server__DOMAIN=project.com

You may want to put that back to VIRTUAL_HOST (again not in 1.13+) and check what your compose was doing with that environment variable.

  • GITEA_DISABLE_REGISTRATION=true

GITEA__service__DISABLE_REGISTRATION=true

GITEA__server__ROOT_URL=https://project.com/gitea/

  • GITEA_DOMAIN=project.com

GITEA__server__DOMAIN=project.com


In general, any setting in the app.ini can be changed using environment variables of the form:

GITEA__SECTION__KEY=value

That is GITEA two underscores section_name two underscores key. Because certain things are not allowed in environment variables you can escape them using _0x followed by the code point - this is useful for keys and section headers with a period in them, so GITEA__UI_0x2E_META__AUTHOR=zeripath maps to the [ui.meta] AUTHOR=zeripath

@zeripath commented on GitHub (May 10, 2021): > Thank you for this - I was using the non GITEA_ ones and have now changed the docker_compose with > environment: You've done these conversions incorrectly, see https://docs.gitea.io/en-us/install-with-docker/#managing-deployments-with-environment-variables > - GITEA_VIRTUAL_PORT=3000 (I'm not sure where this comes from ... it wasn't in release/v1.13 or 1.14 or main) The closest equivalent is: `GITEA__server__HTTP_PORT=3000` but you may want to put it back to `VIRTUAL_PORT=3000` and add the above too. > - GITEA_VIRTUAL_HOST=project.com This one I'm really not sure about, nearest is `DOMAIN`: `GITEA__server__DOMAIN=project.com` You may want to put that back to `VIRTUAL_HOST` (again not in 1.13+) and check what your compose was doing with that environment variable. > - GITEA_DISABLE_REGISTRATION=true `GITEA__service__DISABLE_REGISTRATION=true` > - GITEA_ROOT_URL=https://project.com/gitea/ `GITEA__server__ROOT_URL=https://project.com/gitea/` > - GITEA_DOMAIN=project.com `GITEA__server__DOMAIN=project.com` --- In general, any setting in the app.ini can be changed using environment variables of the form: `GITEA__SECTION__KEY=value` That is `GITEA` two underscores `section_name` two underscores `key`. Because certain things are not allowed in environment variables you can escape them using `_0x` followed by the code point - this is useful for keys and section headers with a period in them, so `GITEA__UI_0x2E_META__AUTHOR=zeripath` maps to the `[ui.meta]` `AUTHOR=zeripath`
Author
Owner

@kdamianakis commented on GitHub (May 10, 2021):

Thank you for this! I shall check this to see if that would work on the official docker image as ENV variables.

@kdamianakis commented on GitHub (May 10, 2021): Thank you for this! I shall check this to see if that would work on the official docker image as ENV variables.
Author
Owner

@techknowlogick commented on GitHub (May 11, 2021):

Closing, please join chat or forum if you require any assistance with the env vars.

@techknowlogick commented on GitHub (May 11, 2021): Closing, please join chat or forum if you require any assistance with the env vars.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#7320