[GH-ISSUE #270] frp透传后在nginx无法获取真实ip,该如何配置 #190

Closed
opened 2026-05-05 11:58:08 -06:00 by gitea-mirror · 5 comments
Owner

Originally created by @GongDexing on GitHub (Mar 9, 2017).
Original GitHub issue: https://github.com/fatedier/frp/issues/270

$remote_addr始终是172.17.0.1,$http_x_forwarded_for始终是空,请问frp这边要如何配置
image
image

Originally created by @GongDexing on GitHub (Mar 9, 2017). Original GitHub issue: https://github.com/fatedier/frp/issues/270 **$remote_addr**始终是172.17.0.1,**$http_x_forwarded_for**始终是空,请问frp这边要如何配置 ![image](https://cloud.githubusercontent.com/assets/20265449/23744329/c2325b06-04ee-11e7-9a1c-cc339b0bd09b.png) ![image](https://cloud.githubusercontent.com/assets/20265449/23744370/f025d75e-04ee-11e7-898a-ffad51ddb46d.png)
gitea-mirror 2026-05-05 11:58:08 -06:00
  • closed this issue
  • added the
    todo
    label
Author
Owner

@fatedier commented on GitHub (Mar 10, 2017):

暂时不支持。

<!-- gh-comment-id:285565852 --> @fatedier commented on GitHub (Mar 10, 2017): 暂时不支持。
Author
Owner

@jearol commented on GitHub (Apr 6, 2017):

同样期待此功能

<!-- gh-comment-id:292063938 --> @jearol commented on GitHub (Apr 6, 2017): 同样期待此功能
Author
Owner

@openmynet commented on GitHub (Apr 23, 2017):

nginx

server {
  listen 80;
  server_name test.*;
  location / {
  client_max_body_size    1000m; 
  proxy_pass http://127.0.0.1:8080;
	proxy_redirect off;
	proxy_set_header X-Real-IP $remote_addr;
	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	proxy_set_header Host $http_host;
	proxy_set_header X-NginX-Proxy true;
 }
}

我后端是express框架写的是可以获取真实的用户IP的

const express = require('express');
const app = express();
app.set('trust proxy', 'loopback'); // 配合nginx使用的
app.get("/ip", function (req, res) {
  res.json({ips:req.ips})
})
app.listen(3000);
<!-- gh-comment-id:296437272 --> @openmynet commented on GitHub (Apr 23, 2017): nginx ``` server { listen 80; server_name test.*; location / { client_max_body_size 1000m; proxy_pass http://127.0.0.1:8080; proxy_redirect off; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; } } ``` 我后端是express框架写的是可以获取真实的用户IP的 ```javascript const express = require('express'); const app = express(); app.set('trust proxy', 'loopback'); // 配合nginx使用的 app.get("/ip", function (req, res) { res.json({ips:req.ips}) }) app.listen(3000); ```
Author
Owner

@oldthreefeng commented on GitHub (Mar 13, 2020):

$remote_addr始终是172.17.0.1,$http_x_forwarded_for始终是空,请问frp这边要如何配置
image
image

请问解决了么, 求一下配置.

<!-- gh-comment-id:598522713 --> @oldthreefeng commented on GitHub (Mar 13, 2020): > **$remote_addr**始终是172.17.0.1,**$http_x_forwarded_for**始终是空,请问frp这边要如何配置 > ![image](https://cloud.githubusercontent.com/assets/20265449/23744329/c2325b06-04ee-11e7-9a1c-cc339b0bd09b.png) > ![image](https://cloud.githubusercontent.com/assets/20265449/23744370/f025d75e-04ee-11e7-898a-ffad51ddb46d.png) 请问解决了么, 求一下配置.
Author
Owner

@jearol commented on GitHub (Mar 13, 2020):

这需要在frp_server外面再加个nginx
本地PHP -> 本地Nginx -> 本地frp_client -> 远程frp_server -> 远程Nginx
只有前4个的话就会始终127.0.0.1,加上最后一个,并且在配置文件里加上proxy_set_header的相关参数就会拿到真实的客户端ip了
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;

Louis notifications@github.com 于2020年3月13日周五 上午10:51写道:

$remote_addr始终是172.17.0.1,$http_x_forwarded_for始终是空,请问frp这边要如何配置
[image: image]
https://cloud.githubusercontent.com/assets/20265449/23744329/c2325b06-04ee-11e7-9a1c-cc339b0bd09b.png
[image: image]
https://cloud.githubusercontent.com/assets/20265449/23744370/f025d75e-04ee-11e7-898a-ffad51ddb46d.png

请问解决了么, 求一下配置.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/fatedier/frp/issues/270#issuecomment-598522713, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/ACRVDFD7PVJVJ64Z6UVUDSTRHGNSFANCNFSM4DC7MNGA
.

--
You may only be a person in this world,but for someone,you are the world.

<!-- gh-comment-id:598572468 --> @jearol commented on GitHub (Mar 13, 2020): 这需要在frp_server外面再加个nginx 本地PHP -> 本地Nginx -> 本地frp_client -> 远程frp_server -> 远程Nginx 只有前4个的话就会始终127.0.0.1,加上最后一个,并且在配置文件里加上proxy_set_header的相关参数就会拿到真实的客户端ip了 proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; Louis <notifications@github.com> 于2020年3月13日周五 上午10:51写道: > *$remote_addr*始终是172.17.0.1,*$http_x_forwarded_for*始终是空,请问frp这边要如何配置 > [image: image] > <https://cloud.githubusercontent.com/assets/20265449/23744329/c2325b06-04ee-11e7-9a1c-cc339b0bd09b.png> > [image: image] > <https://cloud.githubusercontent.com/assets/20265449/23744370/f025d75e-04ee-11e7-898a-ffad51ddb46d.png> > > 请问解决了么, 求一下配置. > > — > You are receiving this because you commented. > Reply to this email directly, view it on GitHub > <https://github.com/fatedier/frp/issues/270#issuecomment-598522713>, or > unsubscribe > <https://github.com/notifications/unsubscribe-auth/ACRVDFD7PVJVJ64Z6UVUDSTRHGNSFANCNFSM4DC7MNGA> > . > -- You may only be a person in this world,but for someone,you are the world.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/frp#190
No description provided.