0

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

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

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

Thanks.

John Siu
  • 5,056
  • 2
  • 26
  • 47
inGame
  • 17
  • 6
  • https is port 443, but your nginx only listens to port 80, which is unencrypted http. Your gogs instance should be served both on port 80 and 3000 with this configuration. You have to configure nginx to also listen to port 443 and provide a certificate, ideally one that matches your domain so that you don't get certificate errors... – Dirk Trilsbeek Jun 01 '19 at 14:31

1 Answers1

0

To bind gogs to specific IP, use HOST_ADDR in the [server] section:

[server]
DOMAIN = git.mydomain.com
HTTP_ADDR = 127.0.0.1
HTTP_PORT = 3000
ROOT_URL = https://git.mydomain.com/
DISABLE_SSH = false
SSH_PORT = 22
START_SSH_SERVER = false
OFFLINE_MODE = false

That will stop gogs from accepting from the network. If it has no effect, then you will need to switch to a newer version of gogs.

For nginx to server https, you need to create/buy or use letsencrypt certificate and configure like following:

server {
    listen 443 ssl;

    server_name git.mydomain.com;

    ssl_certificate <cert.pem>; # Full path of your cert file
    ssl_certificate_key <key.pem>; # Full path of your key file

    location / {
            proxy_set_header X-Real-IP $remote_addr;
            proxy_pass http://127.0.0.1:8088/;
    }
}
John Siu
  • 5,056
  • 2
  • 26
  • 47