本项目是一个简洁美观的IP显示网站,支持检测访问者真实IP和代理IP,并根据访问方式(浏览器或curl)自动适配展示格式。
- 自动显示访问者的真实IP地址
- 支持显示代理IP(如通过代理访问)
- 浏览器访问时展示现代风格网页,移动端自适应
- curl等命令行访问时返回纯文本格式,便于脚本集成
pip3 install -r requirements.txt --break-system-packagespython3 app.py默认监听8000端口,可通过 http://127.0.0.1:8000 访问。
推荐使用Gunicorn+Nginx:
pip3 install gunicorn
# 启动服务
nohup gunicorn -w 2 -b 0.0.0.0:8000 app:app &Nginx配置示例:
server {
listen 80;
server_name yourdomain.com;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}将域名A记录解析到服务器公网IP即可通过域名访问。
├── app.py # 主程序
├── requirements.txt # 依赖列表
├── templates/
│ └── index.html # 网页模板
- 如遇端口占用,可修改
app.py中的端口号 - 推荐使用HTTPS,可用Let’s Encrypt免费证书
MIT