Change localhost:3000 to sub-domain address

I’m trying to change url of my gogs from localhost to my sub-domain.

Using NGINX.
Configured my sub-domain for git. mydomain. example
then added to nginx.conf http section:
server {
listen 80;
server_name git. mydomain. com;
location / {
proxy_pass http://localhost:3000;
}
}

gogs/custom/app.ini:
[server]
DOMAIN = git. mydomain. com
HTTP_PORT = 3000
ROOT_URL = https://git. mydomain. com/
DISABLE_SSH = false
SSH_PORT = 22
START_SSH_SERVER = false
OFFLINE_MODE = false

(domains without spaces, gogs don’t allow me use more than 2 links since im new)

But it’s still available under address git. mydomain. com:3000 on http protocol, but under git. mydomain. com on https it’s not.

Googed a lot, nothing helps. Mb someone here could help me.

Thanks.

You config looks good at first glance, what is the error message?

For Gogs to be available on HTTPS https://git.mydomain.com:3000, you need to enable it and add a certificate and key via app.ini:

PROTOCOL = https
CERT_FILE = /path/to/cert.pem
KEY_FILE = /path/to/privkey.pem

https://gogs.io/docs/advanced/configuration_cheat_sheet#server-(server)

Or you mean to access via https://git.mydomain.com (default port 443 instead of 3000), so accessing via Nginx on HTTPS? Then you additionally need a HTTPS section (listen 443) and cert + key in your Nginx config of course.

Btw. wrap your copied code as “Preformatted Text”, which is much more readable and does not expand URLs :wink:.

1 Like