目前判断根因是没有拿到实际的IP,因为用了宝塔、Nginx以及docker中的一层Nginx
解决方式如下:
server {
listen 80;
listen 443 ssl;
http2 on;
server_name lifes.fun www.lifes.fun;# ↓ 加在这里(server 级,只对本站点生效) set_real_ip_from 127.0.0.1; set_real_ip_from 172.16.0.0/12; real_ip_header X-Forwarded-For; real_ip_recursive on; ...}
var/containers/app.yml要加内容:
env:
DISCOURSE_TRUSTED_PROXIES: "127.0.0.1,172.17.0.1/32,172.17.0.0/16"
run下面要增加:
- file:
path: /etc/nginx/conf.d/outlets/server/real-ip-header.conf
chmod: 644
contents: |
real_ip_header X-Forwarded-For;
- file:
path: /etc/nginx/conf.d/outlets/server/set-real-ip-from-host.conf
chmod: 644
contents: |
set_real_ip_from 172.17.0.1/32;
set_real_ip_from 172.17.0.0/16;
- file:
path: /etc/nginx/conf.d/outlets/server/real-ip-recursive.conf
chmod: 644
contents: |
real_ip_recursive on;
