[英]Meteor's FlowRouter.url() returning IP address of host, not FQDN
[英]Access client's IP address (not the load balancer's) from Meteor, with Modulus
我有一個https Meteor webapp托管在factor.io上 。 按照這里的建議,我有一個服務器方法:
Meteor.methods({
printIP: function() {
return this.connection.clientAddress;
}
});
我從現場站點的瀏覽器控制台中調用此命令:
Meteor.call('printIP', function(err, ip) { console.log(ip); })
但這總是返回Modulus的負載平衡器的IP地址54.236.216.66。
如何訪問客戶端的IP地址而不是負載均衡器的IP地址?
謝謝!
通過一些實驗,我找到了一個解決方案:
Meteor.methods({
printIP: function() {
if (this.connection.httpHeaders && this.connection.httpHeaders['x-forwarded-for']) {
return this.connection.httpHeaders['x-forwarded-for'];
} else {
return this.connection.clientAddress;
}
}
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.