Giter VIP home page Giter VIP logo

docker-nginx-kestrel's Introduction

ASP.NET Core HTTPS & Load balancing

Deploy an ASP.NET Core application with HTTPS & Load balancing using Docker and NGINX as reverse proxy.

To get started:

    docker-compose build
    docker-compose scale core-app=4
    docker-compose up

IMPORTANT: Due to NGINX (Free version) limiations, current configuration is set to work with a fixed scale of 4 nodes. With NGINX Plus, additional changes might be applied to scale up and down dynamically.

docker-nginx-kestrel's People

Contributors

johnsnowdies avatar sesispla avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

docker-nginx-kestrel's Issues

Not working on Windows

> docker-compose build
Building core-app
Step 1/8 : FROM microsoft/dotnet
 ---> c7f0db36c01b
Step 2/8 : RUN printf "deb http://ftp.us.debian.org/debian jessie main\n" >> /etc/apt/sources.list
 ---> Running in 2a5417c85698
 ---> f64293d3ff07
Removing intermediate container 2a5417c85698
Step 3/8 : COPY . /app
 ---> 3e9f828e8286
Removing intermediate container 929481eaec4a
Step 4/8 : WORKDIR /app
 ---> 093e4c4e4a59
Removing intermediate container 9d1f6927824b
Step 5/8 : RUN dotnet restore
 ---> Running in 2b8a6898f772
MSBUILD : error MSB1003: Specify a project or solution file. The current working directory does not contain a project or solution file.
ERROR: Service 'core-app' failed to build: The command 'dotnet restore' returned a non-zero code: 1

[Question] Debugging Docker with this workflow?

Hey @sesispla I was just wondering, so considering this is all in a solution together.

Is a Dev supposed to be running all of this within Docker (.NET Core app, Nginx) and debugging it that way? Let's say there were many other layers, micro-services, etc as well, that needed to be setup with Docker.

New-ish to the Docker world, just wondering how one goes about debugging and developing in this workflow. Thanks for any input ๐Ÿ‘

docker network settings

What network settings do you have setup for docker? I tried what you have, but it wouldn't load balance as I would expect. I have nginx setup to serve on port 5100 and my dotnet app on 5000.

In my dotnet app's Dockerfile, I expose 5000
and in nginx.conf:

worker_processes 1;

events { worker_connections 1024; }

http {

    include mime.types; #include the required MIME types
    sendfile on;

    # List of application servers
    upstream api {

        server api1:5000;
        server api2:5000;
        server api3:5000;

    }

    # Configuration for the server
    server {

        # Running port
        listen 5100;		

        # Proxying the connections
        location / {

            proxy_pass         http://api;
            proxy_redirect     off;
            proxy_set_header   Host $host;
            proxy_set_header   X-Real-IP $remote_addr;
            proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header   X-Forwarded-Host $server_name;
			proxy_set_header   X-Forwarded-Proto $scheme;   
        }
    }
}

In the logs I have this:

172.22.0.1 - - [01/Nov/2017:17:31:20 +0000] "GET /api/values HTTP/1.1" 502 575 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36"
2017/11/01 17:31:20 [error] 5#5: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 172.22.0.1, server: , request: "GET /api/values HTTP/1.1", upstream: "http://127.0.0.1:5000/api/values", host: "api:5100"

I suspect that the bridged mode networking is causing some issues here.

[Suggestion] New NET Core project format

Hey, @sesispla ! Found this repo very useful, but not working.
dotnet restore
produces next error:
MSBUILD : error MSB1003: Specify a project or solution file. The current working directory does not contain a project or solution file. ERROR: Service 'core-app' failed to build: The command 'dotnet restore' returned a non-zero code: 1

As I found, Microsoft changed project format at last NET Core release and project.json doesn't works anymore.

There is a simple way to fix this:
dotnet migrate

I've did it in my Fork

Best regards,
Sergey

502 Bad Gateway

I want to run my asp.net application at nginx server, But I am facing the following error in dev environment
"502 Bad Gateway". Information of docker compose and nginx is given below respectively

-------docker compose ----------

`version: '3.4'

services:
webapplication1:
image: ${DOCKER_REGISTRY-}webapplication1
build:
context: .
dockerfile: WebApplication1/Dockerfile
expose:
- "5050"
networks:
- app-network

db1:
image: microsoft/mssql-server-linux
container_name: db1
environment:
SA_PASSWORD: "Thingtrax%1"
ACCEPT_EULA: "Y"
MSSQL_PID: Express
ports:
- "7004:1433"
networks:
app-network:
ipv4_address: 172.27.0.3

web_nginx:
image: nginx
ports:
- "8088:80"
volumes:
- ${APPDATA}/nginx/nginx.conf:/etc/nginx/nginx.conf
depends_on:
- webapplication1
- db1
networks:
- app-network
container_name: web_nginx
restart: always

networks:
app-network:
ipam:
driver: default
config:
- subnet: 172.27.0.0/16`

nginx.conf###

worker_processes 4;

events { worker_connections 1024; }

http {
sendfile on;

upstream webapplication {
    server webapplication1:5050;
}

server {
    listen 80;

    location / {
        proxy_pass         http://webapplication;
        proxy_redirect     http://localhost http://webapplication;
        proxy_set_header   Host $host;
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header   X-Forwarded-Host $server_name;

    }
}

}

Please help me to solve this issue

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.