【发布时间】:2019-11-27 15:10:12
【问题描述】:
我的问题是在 nginx 级别从网络获取“真实”IP 地址,通过 ssl 为静态 vuejs 站点提供服务。
我想阻止某些IP地址,如果我不能使用代理通行证,我怎样才能获得真实的IP地址,因为我只链接到一个静态位置?
haproxy (tcp) (port: 443) ==> 加密请求 ==> nginx (port: 8085) 请求传递到 ==> '/' 位置获取真实 IP 以进行范围阻塞。
另请参阅 nginx vhost 文件中的问题/cmets。我是在正确的轨道上还是需要完全不同的方式?
haproxy 设置:
frontend ssl_front_433 xx.xx.xx.xx:443
mode tcp
option tcplog
use_backend ssl_nginx_backend_8085
backend ssl_nginx_backend_8085
mode tcp
balance roundrobin
option tcp-check
server srv-2 127.0.0.1:8085 check fall 3 rise 2 inter 4s
nginx 设置:
server {
listen 8085 ssl;
server_name mydomain;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
ssl_certificate ./fullchain.pem;
ssl_certificate_key ./privkey.pem;
include include.d/ssl.conf;
// I want to only allow certain ip addresses
// haproxy of course always returns 127.0.0.1 thus this is not working
include include.d/ip_range.conf;
location / {
//how to get the proxy headers to be applied here?
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
// do I need a proxy pass and if so where should I pass to,
// in order to use it with static html/js?
// can I use an upstream to a static location?
//proxy_pass http://;
try_files $uri $uri/ /index.html;
}
}
【问题讨论】:
-
Stack Overflow 是一个编程和开发问题的网站。对于这个问题,您可能应该使用Stack Exchange network 上的另一个站点。另请参阅帮助中心的What topics can I ask about here。
标签: linux vue.js nginx haproxy