Skip to content

Commit

Permalink
Driver fingerprinting will now detect the ASP.NET Hosting bundle and …
Browse files Browse the repository at this point in the history
…rewrite module.
  • Loading branch information
sevensolutions committed Oct 6, 2024
1 parent d92921f commit 153c78d
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/NomadIIS/Services/Grpc/DriverService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ public override async Task Fingerprint ( FingerprintRequest request, IServerStre
if ( File.Exists( inetMgr ) )
iisVersion = FileVersionInfo.GetVersionInfo( inetMgr ).ProductVersion;

// Check for availability of some common modules
var aspnetCoreAvailable = File.Exists( Environment.ExpandEnvironmentVariables( @"%ProgramFiles%\IIS\Asp.Net Core Module\V2\aspnetcorev2.dll" ) );
var rewriteModuleAvailable = File.Exists( Environment.ExpandEnvironmentVariables( @"%SystemRoot%\System32\inetsrv\rewrite.dll" ) );

try
{
#if MANAGEMENT_API
Expand Down Expand Up @@ -109,6 +113,8 @@ public override async Task Fingerprint ( FingerprintRequest request, IServerStre
{
{ $"driver.{PluginInfo.Name}.version", new Hashicorp.Nomad.Plugins.Shared.Structs.Attribute(){ StringVal = PluginInfo.Version } },
{ $"driver.{PluginInfo.Name}.iis_version", new Hashicorp.Nomad.Plugins.Shared.Structs.Attribute(){ StringVal = iisVersion } },
{ $"driver.{PluginInfo.Name}.iis_aspnet_core_available", new Hashicorp.Nomad.Plugins.Shared.Structs.Attribute(){ BoolVal = aspnetCoreAvailable } },
{ $"driver.{PluginInfo.Name}.iis_rewrite_module_available", new Hashicorp.Nomad.Plugins.Shared.Structs.Attribute(){ BoolVal = rewriteModuleAvailable } },
{ $"driver.{PluginInfo.Name}.directory_security_enabled", new Hashicorp.Nomad.Plugins.Shared.Structs.Attribute(){ BoolVal = _managementService.DirectorySecurity } },
{ $"driver.{PluginInfo.Name}.udp_logging_enabled", new Hashicorp.Nomad.Plugins.Shared.Structs.Attribute(){ BoolVal = _managementService.UdpLoggerPort is not null } },
{ $"driver.{PluginInfo.Name}.target_websites_enabled", new Hashicorp.Nomad.Plugins.Shared.Structs.Attribute(){ BoolVal = _managementService.AllowedTargetWebsites.Length > 0 } },
Expand Down
31 changes: 31 additions & 0 deletions website/docs/tips-and-tricks/constraining-jobs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Constraining Jobs

Here are a few examples of common job constraints which may be helpful when using *Nomad IIS*.

## Run a .NET (Core) App

Running a .NET App on IIS requires the node to have the [.NET Core Hosting Bundle](https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/hosting-bundle) installed.
The following constraint will ensure that the job is only placed on nodes, having this bundle installed.

```hcl
constraint {
attribute = "${attr.driver.iis.iis_aspnet_core_available}"
value = true
}
```

:::tip
For running .NET Core Apps on IIS it is also suggested to set `managed_runtime_version` to `None` in the [task configuration](../getting-started/task-configuration.md).
:::

## Using the URL-Rewrite Module

The URL-Rewrite Module also needs to be installed separately by [downloading from here](https://www.iis.net/downloads/microsoft/url-rewrite).
The following constraint will ensure that the job is only placed on nodes, having this module installed.

```hcl
constraint {
attribute = "${attr.driver.iis.iis_rewrite_module_available}"
value = true
}
```
2 changes: 1 addition & 1 deletion website/docs/tips-and-tricks/working-with-certificates.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ EOH

### Self Signed Certificate

For quick testing, it may be helpfull to use a self-signed certificate.
For quick testing, it may be helpful to use a self-signed certificate.
*Nomad IIS* can provision one on-demand as shown in the following example.
These certificates will have a lifetime of one year.

Expand Down

0 comments on commit 153c78d

Please sign in to comment.