Hi, how do you run forgejo under a reverse proxy while using an ssh channel to pull/push commits?

From what I understand caddy is only able to proxy http traffic.

  • irotsoma@lemmy.world
    link
    fedilink
    English
    arrow-up
    0
    ·
    6 days ago

    There’s really no need to reverse proxy ssh. What are you attempting to accomplish with the reverse proxy exactly? Http proxying allows you to add things like TLS encryption and modify headers. But ssh is a secure protocol already and you can’t really modify much in transit.

  • stupidcasey@lemmy.world
    link
    fedilink
    English
    arrow-up
    0
    ·
    6 days ago

    Learn NGINX that is the only answer, it’s a B!+€# to get configured but once you know how it will save you so much time, If you want cheat mode run the docker image and use the web interface but make sure to rtfm there are some gotch ya’s

  • Kekin@lemy.lol
    link
    fedilink
    English
    arrow-up
    0
    ·
    6 days ago

    Not really through Caddy but for my setup I have it so the ssh port for Forgejo is only accessible through tailscale. So for push/pulling updated my ssh config file to something like

    Host git.mysite.com HostName tailscaleMachineName User git Port 1234

    Then doing git pull git@git.mysite.com:user/project.git works just fine as long as I am connected to tailscale

    Otherwise you could open the port for Forgejo’s ssh so that you can access it without any vpn

    • wireless_purposely832@lemmy.world
      link
      fedilink
      English
      arrow-up
      0
      ·
      4 days ago

      I feel silly for not realizing that the SSH config would be used by Git!

      I thought if Forgejo’s SSH service listened to a non-standard port that you would have to do commands with the port in the command similar to below (following your example). I guess I assumed Git did not directly use the client’s SSH service.

      git pull git@git.mysite.com:1234:user/project.git
      
      • moonpiedumplings@programming.dev
        link
        fedilink
        English
        arrow-up
        0
        ·
        6 days ago

        Because forgejo’s ssh isn’t for a normal ssh service, but rather so that users can access git over ssh.

        Now technically, a bastion should work, but it’s not really what people want when they are trying to set up git over ssh. Since git/ssh is a service, rather than an administrative tool, why shouldn’t it be configured within the other tools used for exposes services? (Reverse proxy/caddy).

        And in addition to that, people most probably want git/ssh to be available publicly, which a bastion host doesn’t do.

  • Asudox@programming.dev
    link
    fedilink
    English
    arrow-up
    0
    ·
    7 days ago

    Afaik you can reverse proxy the ssh connection. I’ve been connecting to my server using the domain and tld (asudox.dev)

    • wireless_purposely832@lemmy.world
      link
      fedilink
      English
      arrow-up
      0
      ·
      7 days ago

      Are you able to provide some details on how you are doing this? I don’t think you can do much with reverse proxies and SSH beyond routing all traffic on port 22 (or the configured SSH port) to whichever port SSH is listening on. In other words, the reverse proxy cannot route SSH traffic for the host on port 22 to the host, route SSH traffic for Forgejo on port 22 to Forgejo’s SSH process, and SFTP traffic on port 22 to the SFTP process - at least not via domain name like a HTTP/HTTPS reverse proxy would work.

      Instead, this would need to be done via IP address where the host SSH process listens on 192.168.1.2, the Forgejo SSH process listens on 192.168.1.3, and the SFTP process listens on 192.168.4. Otherwise, each of those services would need to use different ports.

      • Asudox@programming.dev
        link
        fedilink
        English
        arrow-up
        0
        ·
        7 days ago

        Upon more investigation, it seems more like caddy indeed can’t. The only reason it works is because I directly point the A record to the VPS’s IP.

  • pe1uca@lemmy.pe1uca.dev
    link
    fedilink
    English
    arrow-up
    0
    ·
    7 days ago

    I can’t give you the technical explanation, but it works.
    My Caddyfile only something like this

    @forgejo host forgejo.pe1uca
    handle @forgejo {
    	reverse_proxy :8000
    }
    

    and everything else has worked properly cloning via ssh with git@forgejo.pe1uca:pe1uca/my_repo.git

    My guess is git only needs the host to resolve the IP and then connects to the port directly.

  • Strit@lemmy.linuxuserspace.show
    link
    fedilink
    English
    arrow-up
    0
    ·
    7 days ago

    If you connect from outside your LAN, you would need to forward the ssh port to the server in your router settings. If you are inside the LAN, just use the ip address of the forgejo server.

  • haui@lemmy.giftedmc.com
    link
    fedilink
    English
    arrow-up
    0
    ·
    7 days ago

    I dont know about caddy but nginx proxy manager does this very well. Also, if running in docker, you can expose the port that runs ssh for forgejo und a different port than the host machine‘s (eg 2222). In that case you just put the remote in with the port and call it a day.

  • Decronym@lemmy.decronym.xyzB
    link
    fedilink
    English
    arrow-up
    0
    ·
    edit-2
    7 days ago

    Acronyms, initialisms, abbreviations, contractions, and other phrases which expand to something larger, that I’ve seen in this thread:

    Fewer Letters More Letters
    Git Popular version control system, primarily for code
    HTTP Hypertext Transfer Protocol, the Web
    IP Internet Protocol
    nginx Popular HTTP server

    3 acronyms in this thread; the most compressed thread commented on today has 11 acronyms.

    [Thread #962 for this sub, first seen 10th Sep 2024, 12:25] [FAQ] [Full list] [Contact] [Source code]

    • wireless_purposely832@lemmy.world
      link
      fedilink
      English
      arrow-up
      0
      ·
      7 days ago

      This would only work if there is no other traffic on the port being used (eg: port 22). If both the host SSH service and Forgejo SSH service expect traffic on port 22, then this would not work since server name indication (SNI) is not provided with SSH traffic and Caddy would not be able to identify the appropriate destination for multiple SSH services traffic.