Code | Color |
---|---|
30 | Black |
31 | Red |
32 | Green |
33 | Yellow |
34 | Blue |
35 | Magenta |
36 | Cyan |
37 | White |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM alpine:3.11 | |
# add a new writable layer on top of the underlying layer(s) | |
CMD ["nginx", "-g", "daemon off;"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
services: | |
nginx: | |
image: nginx:alpine | |
hostname: 'nginx' | |
volumes: | |
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro | |
- ./nginx/proxy.conf:/etc/nginx/proxy.conf:ro | |
- ./nginx/ssl/localhost.crt:/etc/ssl/certs/localhost.crt:ro | |
- ./nginx/ssl/localhost.key:/etc/ssl/certs/localhost.key:ro |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen *:80 default_server; | |
add_header Strict-Transport-Security max-age=15768000; | |
return 301 https://$host$request_uri; | |
} | |
server { | |
listen 443 ssl; | |
server_name $hostname; | |
ssl_certificate /etc/ssl/certs/localhost.crt; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
services: | |
nginx: | |
image: nginx:alpine | |
hostname: 'nginx' | |
volumes: | |
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro | |
- ./nginx/proxy.conf:/etc/nginx/proxy.conf:ro | |
- ./nginx/logs/:/var/log/nginx/ | |
ports: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
proxy_redirect off; | |
proxy_http_version 1.1; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_cache_bypass $http_upgrade; | |
proxy_set_header Connection keep-alive; | |
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-Proto $scheme; | |
proxy_set_header X-Forwarded-Host $server_name; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user nginx; | |
worker_processes auto; | |
events { worker_connections 1024; } | |
http { | |
include /etc/nginx/proxy.conf; | |
include /etc/nginx/mime.types; | |
limit_req_zone $binary_remote_addr zone=one:10m rate=5r/s; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-alpine AS build | |
WORKDIR /app | |
COPY *.sln . | |
COPY MyWebApi/*.csproj ./MyWebApi/ | |
RUN dotnet restore | |
COPY MyWebApi/. ./MyWebApi/ | |
WORKDIR /app/MyWebApi | |
RUN dotnet publish -c Release -o /out --no-restore |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.UseEndpoints(endpoints => | |
{ | |
endpoints.MapControllers(); | |
endpoints.MapGet("/", async context => | |
{ | |
context.Response.ContentType = "text/plain"; | |
// Host info | |
var name = Dns.GetHostName(); // get container id | |
var ip = Dns.GetHostEntry(name).AddressList.FirstOrDefault(x => x.AddressFamily == AddressFamily.InterNetwork); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void ConfigureServices(IServiceCollection services) | |
{ | |
services.AddControllers(); | |
services.Configure<ForwardedHeadersOptions>(options => | |
{ | |
options.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto; | |
}); | |
} | |
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) |