Ssl gitea使用普通用户和https

Ssl gitea使用普通用户和https,ssl,https,iptables,gitea,Ssl,Https,Iptables,Gitea,我正在尝试将gitea设置为使用https,并使用从letsencrypt获得的证书,该证书作为普通用户运行服务 我已经让它在端口80上与一个普通用户使用httpgit,并使用iptables将端口80重定向到端口3000 另外,我已经在端口3000上使用https将其重定向到端口3080 但我不知道如何配置它(可能与iptables一起),以便对端口80的请求重定向到相应的端口(3000?3080?) 我将此iptables命令作为根用户重定向端口80到端口3000: #iptables-t

我正在尝试将gitea设置为使用https,并使用从letsencrypt获得的证书,该证书作为普通用户运行服务

我已经让它在端口80上与一个普通用户使用http
git
,并使用iptables将端口80重定向到端口3000

另外,我已经在端口3000上使用https将其重定向到端口3080

但我不知道如何配置它(可能与iptables一起),以便对端口80的请求重定向到相应的端口(3000?3080?)

我将此iptables命令作为根用户重定向端口80到端口3000:

#iptables-t nat-A预路由-p tcp-dport 80-j重定向-到端口3000

这是我的HTTP配置的相关部分

RUN_USER         = git

LOCAL_ROOT_URL   = http://localhost:3000/
DOMAIN           = example
HTTP_PORT        = 80
ROOT_URL         = http://example.com
这是我对端口3000上HTTP重定向到端口3080的配置

RUN_USER            = git

PROTOCOL            = https
LOCAL_ROOT_URL      = https://localhost:3000/
DOMAIN              = example.com
HTTP_PORT           = 3000
REDIRECT_OTHER_PORT = true
PORT_TO_REDIRECT    = 3080
ROOT_URL            = https://example.com
CERT_FILE           = /etc/letsencrypt/live/example.com/fullchain.pem
KEY_FILE            = /etc/letsencrypt/live/example.com/privkey.pem
使用此配置,我可以访问
https://example.com:3000
它工作正常,但如果我访问
https://example.com:3080
我获得一个
安全连接失败
,错误代码为:SSL\u错误\u RX\u记录太长

我尝试使用iptables将端口80重定向到端口3080,但没有成功


你能帮我设置一下吗?这样我就可以在80端口以普通用户的身份运行服务,这样人们就可以在
https://example.com
?(可能预先将iptables用作根目录以重定向某些端口)提前感谢

HTTPS的端口是443。大多数人会通过使用反向代理而不是iptables来解决这个问题

Gitea可以自行处理letsencrypt。以下是方法:

[server]
PROTOCOL=https
DOMAIN=git.example.com
ENABLE_LETSENCRYPT=true
LETSENCRYPT_ACCEPTTOS=true
LETSENCRYPT_DIRECTORY=https
LETSENCRYPT_EMAIL=email@example.com

摘自:

如果其他人需要,这里是最终的配置文件,它将http请求重定向到https

我使用了ptman建议的
#setcap cap_net_bind_service=+ep/path/to/binary/gitea

RUN_USER            = git

[server]
PROTOCOL            = https
DOMAIN              = example.com
HTTP_PORT           = 443
REDIRECT_OTHER_PORT = true
CERT_FILE           = /etc/letsencrypt/live/example.com/fullchain.pem
KEY_FILE            = /etc/letsencrypt/live/example.com/privkey.pem
SSH_DOMAIN          = example.com
DISABLE_SSH         = false
SSH_PORT            = 22
OFFLINE_MODE        = false

letsencrypt api包含在gitea中。要使用docker compose设置gitea并进行加密,只需编辑您的[server]配置,如下所示:

....
[server]
APP_DATA_PATH    = /data/gitea
DOMAIN           = example.com
SSH_DOMAIN       = example.com
HTTP_PORT        = 443
ROOT_URL         = http://example.com
PROTOCOL=https
ENABLE_LETSENCRYPT=true
LETSENCRYPT_ACCEPTTOS=true
LETSENCRYPT_DIRECTORY=https
LETSENCRYPT_EMAIL=info@foo.com
.....
  server:
    image: gitea/gitea:1.13.2
    container_name: gitea
    ports:
      - "443:443"
      - "222:22"
....
您的docker-compose.yaml端口配置如下所示:

....
[server]
APP_DATA_PATH    = /data/gitea
DOMAIN           = example.com
SSH_DOMAIN       = example.com
HTTP_PORT        = 443
ROOT_URL         = http://example.com
PROTOCOL=https
ENABLE_LETSENCRYPT=true
LETSENCRYPT_ACCEPTTOS=true
LETSENCRYPT_DIRECTORY=https
LETSENCRYPT_EMAIL=info@foo.com
.....
  server:
    image: gitea/gitea:1.13.2
    container_name: gitea
    ports:
      - "443:443"
      - "222:22"
....

这要求普通用户能够打开端口80,我的问题是不必以root
setcap\u net\u bind\u service=+ep/path/to/binary/gitea运行服务