Skip to content

wilsonstone/getip

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

IP显示网站

本项目是一个简洁美观的IP显示网站,支持检测访问者真实IP和代理IP,并根据访问方式(浏览器或curl)自动适配展示格式。

功能特性

  • 自动显示访问者的真实IP地址
  • 支持显示代理IP(如通过代理访问)
  • 浏览器访问时展示现代风格网页,移动端自适应
  • curl等命令行访问时返回纯文本格式,便于脚本集成

快速开始

1. 安装依赖

pip3 install -r requirements.txt --break-system-packages

2. 本地运行

python3 app.py

默认监听8000端口,可通过 http://127.0.0.1:8000 访问。

3. 生产环境部署

推荐使用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免费证书

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors