-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Swagger redirects to port 8080 when using BASE_URL #4385
Copy link
Copy link
Open
Labels
Description
| Q | A |
|---|---|
| Bug or feature request? | Bug |
| Which Swagger/OpenAPI version? | 3 |
| Which Swagger-UI version? | 3.13.1/latest |
| How did you install Swagger-UI? | With the docker image, behind an nginx reverse proxy |
| Which browser & version? | Chrome, Safari... |
| Which operating system? | MacOS X |
Configuration (browser query string, constructor, config.yaml)
Docker-compose.yml
version: '3.5'
services:
gateway:
build: ./nginx
ports:
- "80:80"
- "443:443"
links:
- swaggerui
swaggerui:
image: swaggerapi/swagger-ui
restart: always
environment:
- BASE_URL=/swaggernginx.conf
# Documentation server
server {
listen 443 ;
include /etc/nginx/proxy.conf;
include /etc/nginx/ssl.conf;
location ^~ /swagger {
proxy_pass http://swaggerui:8080;
}
}curl -v http://doc.dev/swagger
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to doc.dev (127.0.0.1) port 80 (#0)
* Server auth using Basic with user 'test'
> GET /swagger HTTP/1.1
> Host: doc.dev
> User-Agent: curl/7.54.0
> Accept: */*
>
< HTTP/1.1 301 Moved Permanently
< Server: nginx
< Date: Wed, 28 Mar 2018 10:50:30 GMT
< Content-Type: text/html
< Content-Length: 185
< Connection: keep-alive
< Location: http://doc.dev:8080/swagger/
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Methods: GET, POST, OPTIONS
< Access-Control-Allow-Headers: DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type
<
<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx/1.10.3</center>
</body>
</html>
* Connection #0 to host doc.dev left intactBUT when I add a final slash
curl -v http://doc.dev/swagger/
# I get the swagger appExpected Behavior
It should work for http://doc.dev/swagger and http://doc.dev/swagger/ (with final slash) as well
Current Behavior
When not adding a final slash, we are redirected to 8080
Context
I have to explain this strange behavior to my teammates and to take care of the links I send.
Reactions are currently unavailable