-
Notifications
You must be signed in to change notification settings - Fork 9k
For dummies, part 1: installing as proxy at your Nginx
(all Linux instructions supposing UBUNTU 16 LTS)
As showed at README, section How to run/Easy start! Docker, you need only two commands,
docker pull swaggerapi/swagger-ui
docker run -p 80:8080 swaggerapi/swagger-ui &
Add &
to preserve the service after close the terminal. Will start Nginx with swagger-ui on port 80.
You can test with curl localhost:80
. At Docker command you say that host port is 80 and container port is 8080. To check container-ID and its ports, use docker ps
... (suppose listing ID b0e5ec5429). To stop service use docker stop b0e5ec5429
.
To use with other pages and webservices in your Nginx websever, the best practice is to manage by Nginx, so you need organize ports. Suppose port 12345, at Docker it is the host port, so change the last command to
docker run -p 12345:8080 swaggerapi/swagger-ui &
Now you can manage it in your Nginx configuration script, suppose domain example.org
and subdomain api-guide
,
server {
server_name api-guide.example.org;
root /var/www/test;
index index.html index.htm;
location / {
try_files $uri $uri/ @proxy;
}
location @proxy {
rewrite ^/etc$ /$1 break;
proxy_pass http://127.0.0.1:12345;
}
}
The proxy is redirecting http://api-guide.example.org
to the Docker container at port 12345.
PS: after changes remember to restart Nginx (with service nginx restart
).
See also: