I have nginx in a docker container and nodejs webapp in another docker container. The nodejs server is accessible from the host server on port 8080.
The dginx nginx container listens on port 80 (it will later execute the certificate, this database should work first).
And now I want the subdomain to be forwarded to this 8080 nodejs application. let's say app1.example.com
From the outside, I can get to the application using the IP server (or host name) and port 8080, but not on app1.example.com. And it works on app1.example.com:8080 (I opened port 8080 on the host server).
I get a message about the wrong nginx gateway when approaching app1.example.com So, I got to the first nginx container, but how do I return to the host server so that the proxy sends it to port 8080 of the host server (and not port 8080 nginx container). looking for the inverse syntax of EXPOSE.
The main problem is, of course, if I use ip and port 127.0.0.1:8080, it will try to use the nginx container .... So, how do I get the nginx container route back to host 127.0.0.1:8080?
I tried 0.0.0.0 and determined upstream, actually a lot of googling, and tried a lot of configurations ... but haven't found a working one yet ...
Edit
Just found out, this docker command can help:
sudo docker network inspect bridge
Ip, ( 172.17..0.2), , ... (, )
Edit
Followning ( ):
docker-compose.yml:
version: "2"
services:
nginx:
container_name: nginx
image: nginx_img
build: ../docker-nginx-1/
ports:
- "80:80"
networks:
- backbone
nodejs:
container_name: nodejs
image: merites/docker-simple-node-server
build: ../docker-simple-node-server/
networks:
- backbone
expose:
- 8080
networks:
backbone:
driver: bridge
nginx ( conf.d):
worker_processes 1;
{worker_connections 1024; }
http {
sendfile on;
upstream upsrv {
server nodejs:8080;
}
server {
listen 80;
server_name app1.example.com;
location / {
proxy_pass http://upsrv;
}
}
}
31-08-2016
this migth , , , srevice :
sudo docker network ls
out puts:
NETWORK ID NAME DRIVER SCOPE
1167c2b0ec31 bridge bridge local
d06ffaf26fe2 dockerservices1_backbone bridge local
5e4ec13d790a host host local
7d1f8c32f259 none null local
edit 01-09-2016
, nginx docker?
, :
FROM ubuntu
MAINTAINER Maintaner Name
RUN apt-get update
RUN apt-get install -y nano wget dialog net-tools
RUN apt-get install -y nginx
RUN rm -v /etc/nginx/nginx.conf
ADD nginx.conf /etc/nginx/
RUN echo "daemon off;" >> /etc/nginx/nginx.conf
EXPOSE 80
CMD service nginx start
1- . 2016
:
version: "2"
services:
nginx:
image: nginx
container_name: nginx
volumes:
- ./nginx-configs:/etc/nginx/conf.d
ports:
- "80:80"
networks:
- backbone
nodejs:
container_name: nodejs
image: merites/docker-simple-node-server
build: ../docker-simple-node-server/
networks:
- backbone
expose:
- 8080
networks:
backbone:
driver: bridge
, docker-compose up -d, nginx-configs. "" nginx /etc/nginx/conf.d
default.cfg nginx, . :
docker exec -t -i _/bin/bash
cat/etc/nginx/conf.d/default.conf
default.conf nginx.
app1.conf :
upstream upsrv1 {
server nodejs:8080;
}
server {
listen 80;
server_name app1.example.com;
location / {
proxy_pass http://upsrv1;
}
}
, ... ..
, ...