Skip to content

LFS Pure SSH implementation uses ROOT_URL instead of LOCAL_ROOT_URL #33839

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
florolf opened this issue Mar 9, 2025 · 8 comments · Fixed by #33840
Closed

LFS Pure SSH implementation uses ROOT_URL instead of LOCAL_ROOT_URL #33839

florolf opened this issue Mar 9, 2025 · 8 comments · Fixed by #33840
Labels
Milestone

Comments

@florolf
Copy link

florolf commented Mar 9, 2025

Description

When using the LFS Pure SSH protocol, the "download" links in the batch responses are generated using setting.AppURL (aka ROOT_URL). While this makes sense for the classic hybrid transport mode where the LFS client needs to connect to the externally facing API URLs to download objects, in the SSH protocol case, subsequent LFS download requests are being originated from the SSH server node.

This causes a number of problems:

  • One major reason to use the SSH protocol in the first place is to avoid having to publicly expose the HTTP LFS endpoints in the first place. However, as implemented, the server side SSH protocol implementation will still try to access the public endpoints (unlike other code which needs to talk to the main Gitea service, which will use LOCAL_ROOT_URL, which can bypass a reverse proxy in front if Gitea.
  • ROOT_URL might not be even accessible from the SSH server node, which will cause obscure failures when cloning a repository (LFS: got status 500 when fetching OID)

Gitea Version

1.23.5

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

No response

Git Version

No response

Operating System

No response

How are you running Gitea?

Self-hosted setup running behind a HTTPS reverse proxy and using OpenSSH for SSH. Both SSH, the reverse proxy and Gitea are running on the same machine, but because of some unrelated peculiar network configuration, the external URL (ROOT_URL) is not accessible locally.

Database

SQLite

@wxiaoguang
Copy link
Contributor

wxiaoguang commented Mar 9, 2025

I don't know why people insist to play with LOCAL_ROOT_URL .... see this for explanation: #32554 (comment) and #32554 (comment) . The document also says that "you do not need to change the default value" https://github.com/go-gitea/gitea/blob/main/custom/conf/app.example.ini#L128-L136

In short: forget it, it is not for end users.

@wxiaoguang
Copy link
Contributor

but because of some unrelated peculiar network configuration, the external URL (ROOT_URL) is not accessible locally.

TBH, ROOT_URL should always be accessible and be used when you need to access to Gitea.

The "peculiar network configuration" should be fixed or use some workaround to make ROOT_URL work.

@florolf
Copy link
Author

florolf commented Mar 9, 2025

I don't know why people insist to play with LOCAL_ROOT_URL

I'm not insisting on playing with it, I'm merely pointing out that there is an inconsistency in how the lfstransfer module handles it. Because of

server, err := url.Parse(setting.LocalURL)
it uses LOCAL_ROOT_URL for all the requests where it constructs the request URL itself, but Download (via
url := action.Href
) uses whatever the previous batch request has returned, which uses ROOT_URL.

This means that this code will break in any configuration where there is a meaningful distinction between ROOT_URL and LOCAL_ROOT_URL.

The "peculiar network configuration" should be fixed or use some workaround to make ROOT_URL work.

I could work around the network issue but my main motivation for wanting to use the SSH LFS transport is avoiding having to expose the HTTP LFS endpoint publicly in the first place, so this wouldn't help.

@florolf
Copy link
Author

florolf commented Mar 9, 2025

The document also says that "you do not need to change the default value" https://github.com/go-gitea/gitea/blob/main/custom/conf/app.example.ini#L128-L136

As a further note: I'm actually not trying to change it from its default value. The default value would be correct but the LFS Download operation is not making use of it, as described above.

@wxiaoguang
Copy link
Contributor

Thank you for the clarification. I see your point, it makes sense.

Let's see how to convert the "public action.Href" to an internal URL ........

@wxiaoguang
Copy link
Contributor

I proposed a PR ( Fix LFS URL #33840 ) and updated the tests. Does it look good to you?

GiteaBot pushed a commit to GiteaBot/gitea that referenced this issue Mar 10, 2025
silverwind pushed a commit that referenced this issue Mar 10, 2025
Backport #33840 by wxiaoguang

Fix #33839

---------

Co-authored-by: wxiaoguang <[email protected]>
hiifong pushed a commit to hiifong/gitea that referenced this issue Mar 10, 2025
Fix go-gitea#33839

(cherry picked from commit c102492)
@florolf
Copy link
Author

florolf commented Mar 10, 2025

I've rebuilt 1.23.5 with this patch on top and tested it in my setup and can confirm that it works, thanks!

@lunny lunny added this to the 1.23.6 milestone Mar 10, 2025
@wxiaoguang
Copy link
Contributor

Thank you very much for the report! The investigation is really helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants