【发布时间】:2020-01-30 15:33:37
【问题描述】:
我正在尝试将 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,我会得到一个Secure Connection Failed 和Error code: SSL_ERROR_RX_RECORD_TOO_LONG。
我尝试使用 iptables 将端口 80 重定向到端口 3080,但没有成功。
您能帮我设置一下,以便我可以在端口 80 中以普通用户身份运行该服务,以便人们可以通过 https://example.com 访问它吗? (也许事先使用 iptables 作为 root 重定向一些端口)提前谢谢
【问题讨论】: