在 Debian 上访问 Swagger 文档,通常取决于你运行的是什么服务(Java / Python / Node / Go 等)。下面按常见场景给你一个完整说明。
Swagger 文档一般是由后端服务自动生成并暴露接口的,不是 Debian 系统自带功能。
常见形式:
http://IP:端口/swagger-ui.htmlhttp://IP:端口/swaggerhttp://IP:端口/api-docshttp://IP:端口/v3/api-docs如果服务运行在本机:
http://localhost:8080/swagger-ui.html
http://127.0.0.1:8080/swagger
在另一台电脑浏览器中访问:
http://服务器IP:端口/swagger-ui.html
⚠️ 如果访问不了,继续看下面排查步骤。
ps -ef | grep java
# 或
ss -lntp
查看端口是否监听:
ss -lntp | grep 8080
Debian 通常使用 nftables 或 ufw:
sudo ufw status
sudo ufw allow 8080
sudo iptables -L -n
很多生产环境会关闭 Swagger。
springdoc:
api-docs:
enabled: true
swagger-ui:
enabled: true
或旧版:
@Profile("dev")
http://IP:8080/swagger-ui.html
http://IP:8080/v3/api-docs
如果用了 springdoc-openapi:
http://IP:8080/swagger-ui/index.html
http://IP:8000/docs
或:
http://IP:8000/redoc
http://IP:3000/api-docs
http://IP:8080/swagger/index.html
在你本地电脑执行:
ssh -L 8080:localhost:8080 user@debian_ip
然后浏览器访问:
http://localhost:8080/swagger-ui.html
curl http://localhost:8080/v3/api-docs
如果你愿意,可以告诉我:
我可以直接给你精确到配置级别的解决方案。