mcdanlj
(Michael K Johnson)
7월 16, 2026, 1:02오후
1
최근 몇 달간(정확히 언제부터 시작되었는지 불분명) 실제 IP 주소를 전달하기 위해 Add an offline page to display when Discourse is rebuilding or starting up 에 문서화된 외부 nginx 구성이 무시되고 있음을 확인했습니다.
이 외부 nginx 구성은 수년간 정상적으로 작동해 왔습니다:
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Real-IP $remote_addr;
현재는 RFC1918 주소 공간의 내부 docker 네트워크로 모든 트래픽이 귀속되고 있으며, 다음과 같습니다:
이는 "이 IP 주소를 공유하는 다른 사용자에게도 이 패널티를 적용한다"는 기능 및 실제 원격 IP 주소의 기타 모든 용도를 명백히 깨뜨리고 있습니다.
어딘가에서 이 문제가 해결되었을 것으로 생각되지만, 제가 검색을 잘 못 하고 있는 것 같습니다. 어떤 부분이 변경되었는지, 그리고 제가 그에 맞게 적응해야 하는지 안내해 주시면 감사하겠습니다.
pfaffman
(Jay Pfaffman)
7월 16, 2026, 1:27오후
2
최근에 이 관련해서 무언가를 기억하는데, 나도 찾을 수가 없습니다. Handling the "chain of trust" of the end user's real IP - #8 by supermathie 에는 Cloudflare 템플릿으로 연결되는 링크가 포함되어 있는데, 이는 좋은 모델이 될 수 있다고 생각합니다.
run:
- file:
path: /etc/nginx/conf.d/outlets/server/real-ip-header.conf
chmod: 644
contents: |
real_ip_header cf-connecting-ip;
- exec:
cmd:
# avoid the trap of specifying both URLs on one curl line; the data might not have a final newline
# print sprintf looks dubious at first, but avoids the problem of "how many times do you backslash a \\\\n"
- curl -s https://www.cloudflare.com/ips-v4/ | awk '{print sprintf("set_real_ip_from %s;", $0)}' > /etc/nginx/conf.d/outlets/server/set-real-ip-from-cloudflare.conf
- curl -s https://www.cloudflare.com/ips-v6/ | awk '{print sprintf("set_real_ip_from %s;", $0)}' >> /etc/nginx/conf.d/outlets/server/set-real-ip-from-cloudflare.conf
제가 현재 수행하고 있는 작업은 여전히 작동하는 것 같습니다(“Discourse 2026.6.0-latest - GitHub - discourse/discourse: A platform for community discussion. Free, open, simple. · GitHub version 5c507d8359f4d6e8a5d98780c622d51cedbd9bd7” 기준)
after_bundle_exec:
- replace:
filename: /etc/nginx/conf.d/discourse.conf
from: "types {"
to: |
set_real_ip_from 192.168.1.0/24;
set_real_ip_from 192.168.11.0/24;
set_real_ip_from 172.16.0.0/12;
set_real_ip_from 10.0.0.0/8;
real_ip_recursive on;
real_ip_header X-Forwarded-For;
types {
아래 커밋과 관련이 있을 수 있습니다: FIX: nginx sample configuration should be setting x-f-f to the end us… · discourse/discourse@b4a3389 · GitHub
아래 링크가 도움이 될 수 있습니다:
Background
Discourse needs to be aware of the end user’s real IP address.
However, an end user never directly connects to Discourse since there is always one or more upstream web servers (nginx running in the Discourse container) in place. Thus, we need a way to pass along that information to Discourse in a trusted manner.
The x-forwarded-for header is the solution. In this topic I will describe the specific mechanisms for properly handling that information and how we’re expecting it to be pro…
mcdanlj
(Michael K Johnson)
7월 16, 2026, 3:16오후
4
예전처럼 게시글을 올리고 반응들을 보면 비슷한 다른 글들을 찾는 데 도움이 됩니다. 예를 들면
Hi,
I have researched quite a lot but nothing seems to work with me.
I have a discourse setup installed. And I have this remote reverse proxy server that acts as a HTTPS layer between the user and the main discourse server..
[image]
I have included these revers proxy settings properly.. But why does it still show my Reverse Proxy server’s IP Address (hostname to be specific)
[image]
감사합니다 여러분! 이제 컨테이너의 nginx에서 set_real_ip_from을 설정하러 갑니다!
다만 RFC1918 전체 공간을 설정할 예정입니다. 다른 분들을 위해 참고용으로 공유하면 다음과 같습니다:
after_bundle_exec:
- replace:
filename: /etc/nginx/conf.d/discourse.conf
from: "types {"
to: |
set_real_ip_from 192.168.0.0/16;
set_real_ip_from 172.16.0.0/12;
set_real_ip_from 10.0.0.0/8;
real_ip_recursive on;
real_ip_header X-Forwarded-For;
types {
mcdanlj
(Michael K Johnson)
7월 16, 2026, 5:07오후
5
제 환경에서는 작동하지 않습니다.
참조된 커밋 때문에 제 환경에서 작동이 멈춘 이유를 이제 이해했습니다. 제가 수년간 사용해 온 set_real_ip 치환이 깨져버린 것이었습니다. 더 견고하게 만들려는 이유는 타당하며, 이는 더 나은 방법입니다. 한 번의 호환성 변경 이후로는 미래에 깨질 가능성이 줄어들 것입니다.
after_bundle_exec 치환이 적용되지 않는 이유는 알 수 없지만, 파일 드롭 방식으로 전환할 예정입니다.
제 환경에서는 이렇게 하면 작동합니다. 다음 사람을 위해 공유합니다:
run:
- file:
path: /etc/nginx/conf.d/outlets/server/real-ip-recursive.conf
chmod: 644
contents: |
real_ip_recursive on;
- 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.conf
chmod: 644
contents: |
set_real_ip_from 192.168.0.0/16;
set_real_ip_from 172.16.0.0/12;
set_real_ip_from 10.0.0.0/8;