diff --git a/ManagementPage/ManagementPage/Database/MongoDbClient.cs b/ManagementPage/ManagementPage/Database/MongoDbClient.cs index 5128470..f04ce5e 100644 --- a/ManagementPage/ManagementPage/Database/MongoDbClient.cs +++ b/ManagementPage/ManagementPage/Database/MongoDbClient.cs @@ -11,7 +11,7 @@ namespace ManagementPage.Database private const string _accountsCollectionName = "Accounts"; private const string _deviceCollectionName = "Devices"; private const string _databaseName = "Environment"; - private const string _uri = "mongodb://192.168.0.159:27017"; + private readonly string _uri; private readonly IMongoDatabase _database; private readonly MongoClient _client; @@ -20,8 +20,9 @@ namespace ManagementPage.Database public IMongoCollection DeviceCollection { get; private set; } - public MongoDbClient() + public MongoDbClient(IConfiguration configRoot) { + _uri = configRoot["mongodb:uri"]; _client = new MongoClient(_uri); _database = _client.GetDatabase(_databaseName); BsonClassMap.RegisterClassMap(cm => diff --git a/ManagementPage/ManagementPage/ManagementPage.csproj.user b/ManagementPage/ManagementPage/ManagementPage.csproj.user index 373ca0d..db202a5 100644 --- a/ManagementPage/ManagementPage/ManagementPage.csproj.user +++ b/ManagementPage/ManagementPage/ManagementPage.csproj.user @@ -6,6 +6,9 @@ RazorPageScaffolder root/Common/RazorPage P:\EnvironmentManagement\ManagementPage\ManagementPage\Properties\PublishProfiles\registry.jacknet.io.pubxml - Docker + ManagementPage + + + ProjectDebugger \ No newline at end of file diff --git a/ManagementPage/ManagementPage/Pages/Error.cshtml b/ManagementPage/ManagementPage/Pages/Error.cshtml index 6f92b95..093dbd4 100644 --- a/ManagementPage/ManagementPage/Pages/Error.cshtml +++ b/ManagementPage/ManagementPage/Pages/Error.cshtml @@ -3,7 +3,7 @@ @{ ViewData["Title"] = "Error"; } - +

Error.

An error occurred while processing your request.

@@ -12,15 +12,4 @@

Request ID: @Model.RequestId

-} - -

Development Mode

-

- Swapping to the Development environment displays detailed information about the error that occurred. -

-

- The Development environment shouldn't be enabled for deployed applications. - It can result in displaying sensitive information from exceptions to end users. - For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development - and restarting the app. -

+} \ No newline at end of file diff --git a/ManagementPage/ManagementPage/appsettings.Development.json b/ManagementPage/ManagementPage/appsettings.Development.json index 128e59b..f6b6893 100644 --- a/ManagementPage/ManagementPage/appsettings.Development.json +++ b/ManagementPage/ManagementPage/appsettings.Development.json @@ -6,6 +6,9 @@ "Microsoft.AspNetCore": "Warning" } }, + "mongodb": { + "uri": "mongodb://192.168.0.159:27017" + }, "oidc": { "region": "openid-connect", "clientid": "51m0n-temperature", diff --git a/docker-compose.yml b/docker-compose.yml index a168885..f76b348 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,14 +2,31 @@ version: "3.4" services: frontend: image: registry.jacknet.io/51m0n/environment-frontend:latest + depends_on: + - database + environment: + - ASPNETCORE_oidc_region=openid-connect + - ASPNETCORE_oidc_clientid=51m0n-temperature + - ASPNETCORE_oidc_clientsecret= + - ASPNETCORE_mongodb_uri=mongodb://database:27017/ database: - image: mongodb:latest + image: mongo:latest apiserver: image: registry.jacknet.io/51m0n/environment-api:latest environment: - - GIN_DB_PATH=mongodb://database:27017 + - GIN_DB_PATH=mongodb://database:27017/ + depends_on: + - database + proxy: image: nginx:latest - + volumes: + - ./nginx.conf:/etc/nginx/nginx.conf:ro + ports: + - "9030:9000" + depends_on: + - apiserver + - frontend + \ No newline at end of file diff --git a/env_page_nginx.conf b/env_page_nginx.conf new file mode 100644 index 0000000..07f34a1 --- /dev/null +++ b/env_page_nginx.conf @@ -0,0 +1,75 @@ +user nginx; +worker_processes auto; + +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; + + keepalive_timeout 65; + + #gzip on; + + # include /etc/nginx/conf.d/*.conf; + + server { + listen 9000; + listen [::]:9000; + server_name localhost; + + # To allow special characters in headers + ignore_invalid_headers off; + # Allow any size file to be uploaded. + # Set to a value such as 1000m; to restrict file size to a specific value + client_max_body_size 1m; + # To disable buffering + proxy_buffering off; + + location /api/ { + proxy_set_header Host $http_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_connect_timeout 300; + # Default is HTTP/1, keepalive is only enabled in HTTP/1.1 + proxy_http_version 1.1; + proxy_set_header Connection ""; + chunked_transfer_encoding off; + + proxy_pass http://apiserver:8080/; + } + + location / { + proxy_set_header Host $http_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_connect_timeout 300; + # Default is HTTP/1, keepalive is only enabled in HTTP/1.1 + proxy_http_version 1.1; + proxy_set_header Connection ""; + chunked_transfer_encoding off; + + proxy_pass http://frontend; + } + } +} \ No newline at end of file