forked from ddrilling/AsbCloudServer
Merge pull request 'Правки по задаче "Убрать хостинг SPA"' (#148) from feature/read-x-real-ip-clients into dev
Reviewed-on: http://test.digitaldrilling.ru:8080/DDrilling/AsbCloudServer/pulls/148
This commit is contained in:
commit
58f0203a0d
161
AsbCloudWebApi/Docs/Nginx/nginx.conf
Normal file
161
AsbCloudWebApi/Docs/Nginx/nginx.conf
Normal file
@ -0,0 +1,161 @@
|
||||
user www-data;
|
||||
worker_processes auto;
|
||||
pid /run/nginx.pid;
|
||||
include /etc/nginx/modules-enabled/*.conf;
|
||||
|
||||
events {
|
||||
worker_connections 768;
|
||||
# multi_accept on;
|
||||
}
|
||||
|
||||
http {
|
||||
|
||||
proxy_cache_path /home/asb/web-content/cache keys_zone=map-cache:1024m;
|
||||
|
||||
server{
|
||||
listen 5085;
|
||||
charset UTF-8;
|
||||
|
||||
location / {
|
||||
root /home/asb/public_files;
|
||||
autoindex on;
|
||||
autoindex_exact_size off;
|
||||
autoindex_format html;
|
||||
autoindex_localtime on;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 5090;
|
||||
proxy_buffering on;
|
||||
proxy_buffer_size 1M;
|
||||
proxy_buffers 48 1M;
|
||||
proxy_cache_lock on;
|
||||
proxy_cache_lock_age 5s;
|
||||
proxy_http_version 1.1;
|
||||
proxy_cache_valid 200 61d;
|
||||
proxy_cache_use_stale error timeout;
|
||||
|
||||
|
||||
#путь до папки с ui-проектом в файловой системе
|
||||
root /home/asb/AsbCloudUI;
|
||||
index index.html;
|
||||
|
||||
location / {
|
||||
try_files $uri /index.html;
|
||||
}
|
||||
|
||||
#запрос, начинающийся с /api или /auth или /hubs
|
||||
location ~ ^/(api|auth|hubs)/ {
|
||||
|
||||
#адрес, на который будут пересылаться запросы от клиентов
|
||||
proxy_pass http://127.0.0.1:5000;
|
||||
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
}
|
||||
|
||||
location /swagger/ {
|
||||
proxy_pass http://127.0.0.1:5000/swagger/;
|
||||
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
}
|
||||
|
||||
location /favicon.ico {
|
||||
alias /home/asb/web-content/images/favicon.ico;
|
||||
add_header Cache-Control "public";
|
||||
expires 4h;
|
||||
}
|
||||
|
||||
location /config.json {
|
||||
alias /home/asb/web-content/config.json;
|
||||
add_header Cache-Control "public";
|
||||
expires 4h;
|
||||
}
|
||||
|
||||
location /images/ {
|
||||
root /home/asb/web-content;
|
||||
add_header Cache-Control "public";
|
||||
expires 4h;
|
||||
}
|
||||
|
||||
location /map/a/ {
|
||||
proxy_pass https://a.tile.openstreetmap.org/;
|
||||
proxy_cache map-cache;
|
||||
proxy_cache_key $request_uri;
|
||||
}
|
||||
location /map/b/ {
|
||||
proxy_pass https://b.tile.openstreetmap.org/;
|
||||
proxy_cache map-cache;
|
||||
proxy_cache_key $request_uri;
|
||||
}
|
||||
location /map/c/ {
|
||||
proxy_pass https://c.tile.openstreetmap.org/;
|
||||
proxy_cache map-cache;
|
||||
proxy_cache_key $request_uri;
|
||||
}
|
||||
location /map/ {
|
||||
proxy_pass https://b.tile.openstreetmap.org/;
|
||||
proxy_cache map-cache;
|
||||
proxy_cache_key $request_uri;
|
||||
}
|
||||
}
|
||||
|
||||
##
|
||||
# Basic Settings
|
||||
##
|
||||
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
tcp_nodelay on;
|
||||
keepalive_timeout 65;
|
||||
types_hash_max_size 2048;
|
||||
# server_tokens off;
|
||||
|
||||
# server_names_hash_bucket_size 64;
|
||||
# server_name_in_redirect off;
|
||||
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
##
|
||||
# SSL Settings
|
||||
##
|
||||
|
||||
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
|
||||
ssl_prefer_server_ciphers on;
|
||||
|
||||
##
|
||||
# Logging Settings
|
||||
##
|
||||
|
||||
access_log /var/log/nginx/access.log;
|
||||
error_log /var/log/nginx/error.log;
|
||||
|
||||
##
|
||||
# Gzip Settings
|
||||
##
|
||||
|
||||
gzip on;
|
||||
|
||||
# gzip_vary on;
|
||||
# gzip_proxied any;
|
||||
# gzip_comp_level 6;
|
||||
# gzip_buffers 16 8k;
|
||||
# gzip_http_version 1.1;
|
||||
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
|
||||
|
||||
##
|
||||
# Virtual Host Configs
|
||||
##
|
||||
|
||||
include /etc/nginx/conf.d/*.conf;
|
||||
include /etc/nginx/sites-enabled/*;
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Org.BouncyCastle.Asn1.Ocsp;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AsbCloudWebApi.Middlewares
|
||||
@ -18,10 +18,11 @@ namespace AsbCloudWebApi.Middlewares
|
||||
public async Task InvokeAsync(HttpContext context)
|
||||
{
|
||||
var service = context.RequestServices.GetRequiredService<AsbCloudApp.Services.IRequerstTrackerService>();
|
||||
var clientIp = context.Request.Headers["X-Real-IP"].FirstOrDefault();
|
||||
var requestLog = new AsbCloudApp.Data.RequestLogDto
|
||||
{
|
||||
UserLogin = context.User.Identity?.Name ?? string.Empty,
|
||||
UserIp = context.Connection?.RemoteIpAddress?.ToString(),
|
||||
UserIp = clientIp ?? context.Connection?.RemoteIpAddress?.ToString(),
|
||||
RequestMethod = context.Request.Method,
|
||||
RequestPath = context.Request.Path.Value,
|
||||
RequestContentLength = context.Request.ContentLength,
|
||||
|
@ -164,11 +164,6 @@ namespace AsbCloudWebApi
|
||||
endpoints.MapHub<TelemetryHub>("/hubs/telemetry");
|
||||
endpoints.MapHub<ReportsHub>("/hubs/reports");
|
||||
});
|
||||
|
||||
app.UseSpa(spa =>
|
||||
{
|
||||
spa.Options.SourcePath = "wwwroot";
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user