在 Debian 上“调试 Swagger”通常分几种场景:
下面按「通用排查思路 + Debian 常见环境」来说明。
ss -lntp | grep <端口>
ps aux | grep swagger
常见端口:
在 Debian 本机:
curl -v http://localhost:8080/swagger-ui.html
或
curl -v http://localhost:8080/v3/api-docs
如果 curl 能通,但浏览器不行 → 通常是防火墙 / 反向代理问题。
sudo ufw status
sudo ufw allow 8080
检查安全组是否放行端口。
如果你用 Nginx 代理 Swagger:
location /swagger-ui/ {
proxy_pass http://127.0.0.1:8080/;
}
调试方法:
sudo nginx -t
sudo tail -f /var/log/nginx/error.log
常见坑:
proxy_pass 结尾 / 不一致Spring Boot 3:
springdoc-openapi-starter-webmvc-ui
Spring Boot 2:
springfox-swagger2
springfox-swagger-ui
/swagger-ui.html/swagger-ui.html 或 /swagger-ui/index.htmljournalctl -u your-spring-service -f
@EnableOpenApi.requestMatchers("/swagger-ui/**", "/v3/api-docs/**").permitAll()
DEBUG=swagger-ui-express node app.js
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(spec));
访问:
http://localhost:3000/api-docs
uvicorn main:app --reload --log-level debug
访问:
/docs
/openapi.json
flask run --debug
/v3/api-docs 是否 404 / 500curl 通如果你愿意,可以告诉我:
我可以给你针对性的调试命令。