SSH connection refused - gitea and nginx on different hosts

I have installed gitea using binary install.

I am able to get access ssh via LAN ip and able to authenticate successfully.
However, I am unable to get SSH access over my domain and getting the following error:

ssh -T -p 8523 git@gitea.domain.com
ssh: connect to host gitea.domain.com port 8523: Connection refused

My nginx server (192.168.1.4) is on a different host than my gitea host (192.168.1.3). My DNS A record points to the nginx server. I am able to get SSH working when I change the DNS A Record to point my gitea host I am able to authenticate via SSH, however, webUI stops working. I have already setup port forwarding on my router to direct traffic to gitea host when using port 8523 (ssh port)

I need to keep the A record point to nginx host so that the webUI is accessible. Any idea on how I can address this issue?

See my app.ini config:

APP_NAME = CompanyName
RUN_USER = git
RUN_MODE = prod

[database]
DB_TYPE  = postgres
HOST     = 192.168.1.4:5432
NAME     = gitea
USER     = gitea
PASSWD   = <redacted>
SCHEMA   =
SSL_MODE = disable
CHARSET  = utf8
PATH     = /var/lib/gitea/data/gitea.db
LOG_SQL  = false

[repository]
ROOT = /var/lib/gitea/data/gitea-repositories

[server]
SSH_DOMAIN       = gitea.domain.com
DOMAIN           = gitea.domain.com
HTTP_PORT        = 3000
ROOT_URL         = https://gitea.domain.com/
DISABLE_SSH      = false
SSH_PORT         = 22
LFS_START_SERVER = true
LFS_JWT_SECRET   = <redacted>
OFFLINE_MODE     = false
SSH_LISTEN_PORT  = 8523
SSH_USER         = git

My Nginx proxy conf:

server {
    listen 443 ssl;
    listen [::]:443 ssl;

    server_name gitea.*;

    include /config/nginx/sslsimple.conf;

    client_max_body_size 0;

    location / {
        include /config/nginx/proxy.conf;
        include /config/nginx/resolver.conf;
        set $upstream_app 192.168.1.3;
        set $upstream_port 3000;
        set $upstream_proto http;
        proxy_pass $upstream_proto://$upstream_app:$upstream_port;
    }
}

Create a second subdomain for the second machine, and SSH using that.

1 Like

That works, I created a new subdomain and setup a URL Rewrite to point to my gitea host and updated my app.ini to the appropriate SSH_DOMAIN and it works! Thank you!