Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: nginx #151

Merged
merged 6 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions EmailSender.ClientApp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.

# dependencies
/node_modules

# testing
/coverage
/reports

# production
/build

# misc
__testrun.dev.sh
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*

# sonar qube
/.sonarqube
/.scannerwork
15 changes: 15 additions & 0 deletions EmailSender.ClientApp/clientapp.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM debian:latest
WORKDIR /usr/share/nginx/html

RUN rm -rf ./*
RUN apt-get update
RUN apt-get upgrade
RUN apt-get -y install bash
RUN apt-get -y install nginx
RUN apt-get -y install nginx-full
RUN apt-get -y install nginx-extras
RUN adduser --system --no-create-home --shell /bin/false --group --disabled-login nginx
RUN chown -R nginx:nginx /var/www/html

CMD /bin/bash -c "nginx -t"
CMD /bin/bash -c "nginx -g 'daemon off;'"
82 changes: 82 additions & 0 deletions EmailSender.ClientApp/nginx/nginx-http.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
include /etc/nginx/modules-enabled/*.conf;

user nginx;
worker_processes 1;

error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;

events {
worker_connections 1024;
}

http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;
#tcp_nopush on;
server_tokens off;
more_clear_headers Server;

keepalive_timeout 65;

gzip on;
gzip_static on;
gzip_disable "msie6";
gzip_proxied any;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_min_length 256;
gzip_types text/plain text/css application/javascript application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/vnd.ms-fontobject application/x-font-ttf font/opentype image/svg+xml image/x-icon;
gunzip on;

server {
listen 80;
server_name ${SERVER_NAME};

error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/html;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}

location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html$is_args$args;

proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffering off;
proxy_cache_valid 200 30m;
proxy_cache_valid 404 1m;

client_max_body_size 10m;
client_body_buffer_size 128k;
}

location /api {
proxy_pass http://backend;
}

location /hc {
proxy_pass http://backend/hc;
}
}
}
93 changes: 93 additions & 0 deletions EmailSender.ClientApp/nginx/nginx-https.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
include /etc/nginx/modules-enabled/*.conf;

user nginx;
worker_processes 1;

error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;

events {
worker_connections 1024;
}

http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;
#tcp_nopush on;
server_tokens off;
more_clear_headers Server;

keepalive_timeout 65;

gzip on;
gzip_static on;
gzip_disable "msie6";
gzip_proxied any;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_min_length 256;
gzip_types text/plain text/css application/javascript application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/vnd.ms-fontobject application/x-font-ttf font/opentype image/svg+xml image/x-icon;
gunzip on;

server {
listen 443 ssl;
server_name ${SERVER_NAME};

ssl_certificate /etc/nginx/wildcard-emailsender.dev.chain;
ssl_certificate_key /etc/nginx/wildcard-emailsender.dev.key;
ssl_trusted_certificate /etc/nginx/wildcard-emailsender.dev.ca;

ssl_session_cache shared:le_nginx_SSL:10m;
ssl_session_timeout 1d;
ssl_session_cache shared:MozSSL:10m;
ssl_session_tickets off;

ssl_dhparam /etc/nginx/ffdhe2048.txt;

ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-CHACHA20-POLY1305;
ssl_prefer_server_ciphers off;

ssl_stapling on;
ssl_stapling_verify on;

add_header Strict-Transport-Security "max-age=63072000" always;
access_log /var/log/nginx/access.log;

location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html$is_args$args;

proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffering off;
proxy_cache_valid 200 30m;
proxy_cache_valid 404 1m;

client_max_body_size 10m;
client_body_buffer_size 128k;
}

location /api {
proxy_pass http://backend;
}

location /hc {
proxy_pass http://backend/hc;
}
}
}
82 changes: 82 additions & 0 deletions EmailSender.ClientApp/nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
include /etc/nginx/modules-enabled/*.conf;

user nginx;
worker_processes 1;

error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;

events {
worker_connections 1024;
}

http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;
#tcp_nopush on;
server_tokens off;
more_clear_headers Server;

keepalive_timeout 65;

gzip on;
gzip_static on;
gzip_disable "msie6";
gzip_proxied any;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_min_length 256;
gzip_types text/plain text/css application/javascript application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/vnd.ms-fontobject application/x-font-ttf font/opentype image/svg+xml image/x-icon;
gunzip on;

server {
listen 80;
server_name localhost;

error_page 404 /404.html;
location = /404.html {
root /usr/share/nginx/html;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}

location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html$is_args$args;

proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffering off;
proxy_cache_valid 200 30m;
proxy_cache_valid 404 1m;

client_max_body_size 10m;
client_body_buffer_size 128k;
}

location /api {
proxy_pass http://backend;
}

location /hc {
proxy_pass http://backend/hc;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="6.0.1" />
<PackageReference Include="SQLitePCLRaw.bundle_e_sqlite3" Version="2.1.8" />
</ItemGroup>

</Project>
45 changes: 22 additions & 23 deletions EmailSender.WebApi/EmailSender.WebApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,30 @@
<LangVersion>10</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Publish>true</Publish>
<IsPackable>true</IsPackable>
<IsPublishable>true</IsPublishable>
<InvariantGlobalization>false</InvariantGlobalization>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<ItemGroup>
<None Include="..\EmailSender.Configuration\appsettings.Development.json">
<Link>appsettings.Development.json</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\EmailSender.Configuration\appsettings.Production.json">
<Link>appsettings.Production.json</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\EmailSender.Backend\EmailSender.Backend.Application\EmailSender.Backend.Application.csproj" />
<ProjectReference Include="..\EmailSender.Services\EmailSender.Services.BehaviourService\EmailSender.Services.BehaviourService.csproj" />
<ProjectReference Include="..\EmailSender.WebApi.Dto\EmailSender.WebApi.Dto.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="10.3.6" />
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="10.0.1" />
Expand All @@ -23,27 +45,4 @@
<PackageReference Include="AspNetCore.HealthChecks.Uris" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\EmailSender.Backend\EmailSender.Backend.Core\EmailSender.Backend.Core.csproj" />
<ProjectReference Include="..\EmailSender.Backend\EmailSender.Backend.Application\EmailSender.Backend.Application.csproj" />
<ProjectReference Include="..\EmailSender.Backend\EmailSender.Backend.Shared\EmailSender.Backend.Shared.csproj" />
<ProjectReference Include="..\EmailSender.Services\EmailSender.Services.BehaviourService\EmailSender.Services.BehaviourService.csproj" />
<ProjectReference Include="..\EmailSender.Services\EmailSender.Services.HttpClientService\EmailSender.Services.HttpClientService.csproj" />
<ProjectReference Include="..\EmailSender.Services\EmailSender.Services.SenderService\EmailSender.Services.SenderService.csproj" />
<ProjectReference Include="..\EmailSender.Services\EmailSender.Services.SmtpService\EmailSender.Services.SmtpService.csproj" />
<ProjectReference Include="..\EmailSender.Services\EmailSender.Services.UserService\EmailSender.Services.UserService.csproj" />
<ProjectReference Include="..\EmailSender.WebApi.Dto\EmailSender.WebApi.Dto.csproj" />
</ItemGroup>

<ItemGroup>
<None Include="..\EmailSender.Configuration\appsettings.Development.json">
<Link>appsettings.Development.json</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="..\EmailSender.Configuration\appsettings.Production.json">
<Link>appsettings.Production.json</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion EmailSender.WebApi/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{
"commandName": "Project",
"launchBrowser": false,
"applicationUrl": "http://localhost:5010",
"applicationUrl": "http://localhost:6001",
"launchUrl": "swagger",
"environmentVariables":
{
Expand Down
Loading
Loading