I'll have a similar setup to this (one node only):
internet
|
[ nginx proxy]
|
[ node ]
--|-----|-- --|-----|--
[ Service A]-[ Service B]
I want to achieve some kind of routing, e.g. like this:
https://server.com/nginx
routes the traffic to the nginx, which forwards it to the clusterhttps://server.com/nginx/a
routes the traffic toService A
https://server.com/nginx/b
routes the traffic toService B
Is there a solution from docker
(cluster internal) which can route traffic depending on the /path/
?
I was using kubernetes
before, where I had the option do define a path
within an ingress
. Is there something similar in docker
?
I have not used ingress, but I believe it just wraps NGINX. As far as I know, docker has no equivalent, but you can, of course, make your own NGINX service that will perform this task for you. A quick example might look like:
server {
listen 80;
server_name example.org www.example.org;
root /data/www;
location / {
index index.html index.php;
}
location ~* \.(gif|jpg|png)$ {
expires 30d;
}
location ~ \.php$ {
fastcgi_pass php_container_name:9000; //NOTE THE CONTAINER *NAME* NOT IP
fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;
include fastcgi_params;
}
}
(taken from http://nginx.org/en/docs/http/request_processing.html)
You would then launch a container built with nginx and your config. Note that you would refer to your other services by name.
Edit: this post - Kubernetes: Ingress vs Load Balancer may explain more and possibly help you translate your current kubernetes solution.