33 | @RenderBody()
34 |
35 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 | @RenderSection("scripts", required: false)
47 |
48 |
49 |
50 | @functions
51 | {
52 | public string GetClientIp()
53 | {
54 | if(Context.Request.Headers.Keys.Contains("X-Forwarded-For", StringComparer.CurrentCultureIgnoreCase))
55 | {
56 |
57 | return Context.Request.Headers["X-Forwarded-For"].First();
58 | }
59 |
60 | return Context.Connection.RemoteIpAddress.ToString();
61 | }
62 | }
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/aspnetcore-dockerswarm.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25420.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{4DFB6013-EC7C-49D7-BB08-DCF4237D580D}"
7 | EndProject
8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{458B447A-F71F-40E0-BB29-60CFE3E5A79D}"
9 | ProjectSection(SolutionItems) = preProject
10 | global.json = global.json
11 | EndProjectSection
12 | EndProject
13 | Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "TokenGen", "src\TokenGen\TokenGen.xproj", "{494BE48B-EADE-4791-B380-9A611EEC5AD8}"
14 | EndProject
15 | Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "RethinkDbLogProvider", "src\RethinkDbLogProvider\RethinkDbLogProvider.xproj", "{35E8A145-382E-4D59-936B-2834A9CED1DB}"
16 | EndProject
17 | Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "LogWatcher", "src\LogWatcher\LogWatcher.xproj", "{DAA4B110-BA2F-49E5-9D11-909432C6C828}"
18 | EndProject
19 | Global
20 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
21 | Debug|Any CPU = Debug|Any CPU
22 | Release|Any CPU = Release|Any CPU
23 | EndGlobalSection
24 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
25 | {494BE48B-EADE-4791-B380-9A611EEC5AD8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
26 | {494BE48B-EADE-4791-B380-9A611EEC5AD8}.Debug|Any CPU.Build.0 = Debug|Any CPU
27 | {494BE48B-EADE-4791-B380-9A611EEC5AD8}.Release|Any CPU.ActiveCfg = Release|Any CPU
28 | {494BE48B-EADE-4791-B380-9A611EEC5AD8}.Release|Any CPU.Build.0 = Release|Any CPU
29 | {35E8A145-382E-4D59-936B-2834A9CED1DB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
30 | {35E8A145-382E-4D59-936B-2834A9CED1DB}.Debug|Any CPU.Build.0 = Debug|Any CPU
31 | {35E8A145-382E-4D59-936B-2834A9CED1DB}.Release|Any CPU.ActiveCfg = Release|Any CPU
32 | {35E8A145-382E-4D59-936B-2834A9CED1DB}.Release|Any CPU.Build.0 = Release|Any CPU
33 | {DAA4B110-BA2F-49E5-9D11-909432C6C828}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
34 | {DAA4B110-BA2F-49E5-9D11-909432C6C828}.Debug|Any CPU.Build.0 = Debug|Any CPU
35 | {DAA4B110-BA2F-49E5-9D11-909432C6C828}.Release|Any CPU.ActiveCfg = Release|Any CPU
36 | {DAA4B110-BA2F-49E5-9D11-909432C6C828}.Release|Any CPU.Build.0 = Release|Any CPU
37 | EndGlobalSection
38 | GlobalSection(SolutionProperties) = preSolution
39 | HideSolutionNode = FALSE
40 | EndGlobalSection
41 | GlobalSection(NestedProjects) = preSolution
42 | {494BE48B-EADE-4791-B380-9A611EEC5AD8} = {4DFB6013-EC7C-49D7-BB08-DCF4237D580D}
43 | {35E8A145-382E-4D59-936B-2834A9CED1DB} = {4DFB6013-EC7C-49D7-BB08-DCF4237D580D}
44 | {DAA4B110-BA2F-49E5-9D11-909432C6C828} = {4DFB6013-EC7C-49D7-BB08-DCF4237D580D}
45 | EndGlobalSection
46 | EndGlobal
47 |
--------------------------------------------------------------------------------
/docker/nginx/nginx.conf:
--------------------------------------------------------------------------------
1 | worker_processes 2; # 2 * Number of CPUs
2 |
3 | # max connections = worker_processes * worker_connections * (K / average $request_time)
4 | events {
5 | worker_connections 2048;
6 | }
7 |
8 | http {
9 |
10 | # enable web sockets protocol
11 | map $http_upgrade $connection_upgrade {
12 | default upgrade;
13 | '' close;
14 | }
15 |
16 | # enable compression
17 | gzip on;
18 | gzip_http_version 1.0;
19 | gzip_proxied any;
20 | gzip_min_length 256;
21 | gzip_types text/plain text/css application/json application/x-javascript
22 | text/xml application/xml application/xml+rss text/javascript
23 | application/vnd.ms-fontobject application/x-font-ttf font/opentype image/svg+xml image/x-icon;
24 |
25 | # hide server version
26 | server_tokens off;
27 |
28 | # log only warn | error | crit
29 | error_log /var/log/nginx/error.log warn;
30 |
31 | # disable access log
32 | access_log /dev/null;
33 |
34 | # let upstream handle 404 and 50x errors
35 | proxy_intercept_errors off;
36 |
37 | # api
38 | upstream tokengen {
39 | server tokengen:5000;
40 | }
41 |
42 | server {
43 | listen 80;
44 | server_name token.api;
45 |
46 | location / {
47 | proxy_pass http://tokengen;
48 | proxy_http_version 1.1;
49 | proxy_set_header Upgrade $http_upgrade;
50 | proxy_set_header Connection $connection_upgrade;
51 | proxy_set_header Host $host;
52 | proxy_cache_bypass $http_upgrade;
53 | proxy_set_header X-Real-IP $remote_addr;
54 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
55 | }
56 | }
57 |
58 | # enable disk caching
59 | proxy_cache_path /tmp/nginx levels=1:2 keys_zone=STATIC:10m inactive=60m max_size=1g;
60 | proxy_cache_key "$scheme$request_method$host$request_uri";
61 |
62 | # app
63 | upstream logwatcher {
64 | server logwatcher:5005;
65 | }
66 |
67 | server {
68 | listen 80;
69 | server_name token.app;
70 |
71 | location / {
72 | proxy_pass http://logwatcher;
73 | proxy_http_version 1.1;
74 | proxy_set_header Upgrade $http_upgrade;
75 | proxy_set_header Connection $connection_upgrade;
76 | proxy_set_header Host $host;
77 | proxy_cache_bypass $http_upgrade;
78 | proxy_set_header X-Real-IP $remote_addr;
79 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
80 |
81 | location ~ \.(svg|jpg|jpeg|gif|png|ico|css|js|woff2)$ {
82 | # browser caching
83 | expires 30d;
84 | add_header Cache-Control "public";
85 | # server caching
86 | proxy_cache STATIC;
87 | proxy_cache_valid 200 301 302 30m;
88 | proxy_cache_bypass $http_cache_control;
89 | add_header X-Proxy-Cache $upstream_cache_status;
90 | proxy_pass http://logwatcher;
91 | }
92 | }
93 | }
94 | }
--------------------------------------------------------------------------------
/src/LogWatcher/Views/Home/Stats.cshtml:
--------------------------------------------------------------------------------
1 | @{
2 | ViewData["Title"] = "Stats";
3 | }
4 |
5 |