侧边栏壁纸
博主头像
Wood Chen

万事如意

  • 累计撰写 242 篇文章
  • 累计创建 203 个标签
  • 累计收到 10 条评论

目 录CONTENT

文章目录

1panel + docker-openresty + discourse + cloudflare 使用socket连接 显示真实用户IP

wood
2025-06-20 / 0 评论 / 0 点赞 / 14 阅读 / 0 字

原贴: https://www.sunai.net/t/754

nginx使用socket代理discourse, 而不是使用端口代理, 优势在于:

  • 提高安全和性能, 少一次 TCP stack
  • discourse官方推荐
  • 不暴露无谓端口
  • UNIX socket 比本地网络通信(比如 localhost:3000)效率更高,省略网络协议栈

Discourse

如果是已部署的修改, 需要重建app /var/discourse/launcher rebuild app

app.yml

templates:
  - "templates/postgres.template.yml"
  - "templates/redis.template.yml"
  - "templates/web.template.yml"
  ## Uncomment the next line to enable the IPv6 listener
  #- "templates/web.ipv6.template.yml"
  - "templates/web.ratelimited.template.yml"
  - "templates/cloudflare.template.yml"
  - "templates/web.socketed.template.yml"
  ## Uncomment these two lines if you wish to add Lets Encrypt (https)
  #- "templates/web.ssl.template.yml"
  #- "templates/web.letsencrypt.ssl.template.yml"

## 此容器应暴露哪些 TCP/IP 端口?
## 如果您希望 Discourse 与另一个 Web 服务器(如 Apache 或 nginx)共享端口,
## 请参阅 https://meta.discourse.org/t/17247 获取详细信息
expose:
  #- "2080:80"   # http
  #- "2443:443" # https

~~~~~~

1panel

需要修改openresty的compose.yml

- /var/discourse:/var/discourse

Pasted image 20250620202924

openresty

unix:/var/discourse/shared/standalone/nginx.http.sock:

Pasted image 20250620203011

成果

不再是cloudflare的IP地址了

不过好像发现用户头像图片加载有点问题, 不太确定, 再看看

Pasted image 20250620203436

评论区