1
0
mirror of https://github.com/mxpv/podsync.git synced 2024-05-11 05:55:04 +00:00

Add nginx container

This commit is contained in:
Maksym Pavlenko
2017-01-20 19:22:02 -08:00
parent 0e68bda8f3
commit 0df41a6405
5 changed files with 32 additions and 8 deletions

View File

@@ -1,13 +1,9 @@
FROM microsoft/aspnetcore:1.0.3
ARG PORT=56247
ARG PUBLISH_DIR="bin/Publish"
WORKDIR /app
ENV ASPNETCORE_URLS http://+:$PORT
EXPOSE $PORT
COPY $PUBLISH_DIR .
RUN apt-get update && \

View File

@@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Authentication;
using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
@@ -72,6 +73,12 @@ namespace Podsync
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
// See https://docs.microsoft.com/en-us/aspnet/core/publishing/linuxproduction
app.UseForwardedHeaders(new ForwardedHeadersOptions
{
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
});
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();

View File

@@ -6,12 +6,11 @@ services:
build:
context: .
dockerfile: Dockerfile
args:
- PORT=80
restart: always
ports:
- 80:80
- 5001
environment:
- ASPNETCORE_URLS=http://*:5001
- Podsync:RedisConnectionString=redis
env_file:
- ~/podsync.env
@@ -20,4 +19,11 @@ services:
command: redis-server --appendonly yes
restart: always
volumes:
- /data/redis:/data
- /data/redis:/data
nginx:
image: nginx
restart: always
ports:
- 80:80
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf

14
src/Podsync/nginx.conf Normal file
View File

@@ -0,0 +1,14 @@
server {
listen 80;
gzip on;
location / {
proxy_pass http://app:5001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}

View File

@@ -6,6 +6,7 @@
"Microsoft.AspNetCore.Authentication.Cookies": "1.0.0",
"Microsoft.AspNetCore.Authentication.OAuth": "1.0.0",
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.HttpOverrides": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.0",
"Microsoft.AspNetCore.Razor.Tools": {
"version": "1.0.0-preview2-final",