gpt4 book ai didi

ssl - gitea 使用普通用户和 https

转载 作者:太空宇宙 更新时间:2023-11-03 13:13:49 26 4
gpt4 key购买 nike

我正在尝试将 gitea 设置为使用 https 和我从 letsencrypt 以普通用户运行服务时获得的证书。

我已经使用普通用户 git 在端口 80 上使用 http 并使用 iptables 将端口 80 重定向到端口 3000。

此外,我已经在端口 3000 上使用 https 重定向到端口 3080。

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

我以 root 身份使用此 iptables 命令将端口 80 重定向到端口 3000:

# iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 3000

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

RUN_USER         = git

LOCAL_ROOT_URL = http://localhost:3000/
DOMAIN = example
HTTP_PORT = 80
ROOT_URL = http://example.com

这是我在 3000 端口重定向到 3080 端口的 HTTP 配置

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_ERROR_RX_RECORD_TOO_LONG

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

你能帮我设置一下,这样我就可以在 80 端口以普通用户身份运行服务,这样人们就可以在 https://example.com 上访问它了吗? (也许预先使用 iptables 作为 root 来重定向一些端口)提前致谢

最佳答案

如果其他人需要它,这里是最终的配置文件,它将 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

关于ssl - gitea 使用普通用户和 https,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58183139/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com