Nginx container

This is a Ngnix container example. In this case, Ngnix will redirect depending on the URL. If the URL is tp-pos.tk, Nginx will redirect to NodeApp2 (specified in docker run command).

Dockerfile

# Set nginx base image 
FROM nginx 
# Copy custom configuration file from the current directory 
COPY nginx.conf /etc/nginx/nginx.conf

Nginx.conf

worker_processes 4;

events { worker_connections 1024; }

http {

        server {
              listen 80;
                server_name tp-pos.tk;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection 'upgrade';
                proxy_set_header Host $host;
                proxy_cache_bypass $http_upgrade;

              location / {
              # nodeapp1 is the name of link container
                proxy_pass http://nodeapp1:8080;
              }

        }
    server {
              listen 80;
                server_name app2.tp-pos.tk;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection 'upgrade';
                proxy_set_header Host $host;
                proxy_cache_bypass $http_upgrade;

              location / {
              # nodeapp2 is the name of link container
                proxy_pass http://nodeapp2:8080;
              }

        }


}

results matching ""

    No results matching ""