keepalive/ping component should have some config options
See original GitHub issueCurrently the KeepAlive component (see https://github.com/umbraco/Umbraco-CMS/blob/v8/dev/src/Umbraco.Web/Scheduling/KeepAlive.cs) uses the _runtime.ApplicationUrl
to send a request to itself. Typically we require that an Umbraco website can send requests to itself based on the external configured URL for the website which normally requires configuring some internal DNS resolution. This might not always be possible in all hosting scenarios, so we want to be able to configure this component with some options:
- Best to create a new interface: IKeepAliveOptions
- The interface should contain 2x properties (for now, maybe more later)
- Disable (bool) - which would forcibly disable keep alive from running
- KeepAliveUrl (string) - this could be null and in which case the KeepAlive component would just continue to use the
_runtime.ApplicationUrl
- The ctor of the
Umbraco.Web.Scheduling.KeepAlive
should then have another ctor parameter of typeIKeepAliveOptions
which could be an optional parameter that defaults to NULL - Then the component’s code needs to be updated to use these options if they are not null
- Then the
Umbraco.Web.Scheduling.SchedulerComponent
needs to be updated to pass in an instance of IKeepAliveOptions in theRegisterKeepAlive
- For now, it will be easiest to create an internal class
KeepAliveOptions
which implementsIKeepAliveOptions
which reads from appSettings, these keys could be used (which could be added as constants toUmbraco.Core.Constants.AppSettings
)- “Umbraco.Web.KeepAlive.Disabled”
- “Umbraco.Web.KeepAlive.Url”
- For now, it will be easiest to create an internal class
(Original post below…)
Umbraco version
I am seeing this issue on Umbraco version: 8.1.3
Reproduction
Bug summary
The Ping
action in the KeepAliveController
only allows local request. If requests are not coming from localhost, the OnlyLocalRequests
attribute returns a 404.
In my case, the ‘umbracoApplicationUrl’ is set to ‘https://admin.mysite.com/umbraco’. This setting is being used by the KeepAlive
RecurringTaskBase..
The task sends an HTTP GET request to ‘https://admin.mysite.com/umbraco/api/keepalive/ping’. When making that request, a 404 is return because of the OnlyLocalRequests
attribute.
This is causing the logs to be full of 404 issues.
Can we change the behavior for the KeepAlive
task so it can use a new base URL setting specifically for KeepAlive
?
Alternatively, it would be great to be able to turn off the KeepAlive functionality?
Specifics
- umbracoApplicationUrl set to ‘https://admin.mysite.com/umbraco’
- admin.mysite.com is proxied through Cloudflare
- site is hosted on Azure App Service
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (6 by maintainers)
Yep for sure, we need some options specifically for keep alive since the umbraco url might not ever be an internally resolvable one. I’ll update the title of this task, add some notes and mark as up for grabs.
Hi, for reference, the controller is here https://github.com/umbraco/Umbraco-CMS/blob/v8/dev/src/Umbraco.Web/Editors/KeepAliveController.cs and the local only attribute is here https://github.com/umbraco/Umbraco-CMS/blob/v8/dev/src/Umbraco.Web/WebApi/Filters/OnlyLocalRequestsAttribute.cs
Normally we recommend that your server hosting the website can access itself on the public URL. Traditionally speaking this might mean changing local DNS settings or even a hosts file. You cannot edit any hosts file on azure app service and i’m unsure if there’s any reasonable work arounds for that. I’m sure it’s possible one way or another but that’s not something I’ve ever looked in to, wonder if some azure experts would know a nice way to do this? I found this but it’s not all that helpful https://stackoverflow.com/questions/45243476/azure-app-service-internal-dns-resolution
A work around (sort of), is to just ignore the error in your log config so it’s not filling up your logs. Of course this still means that the keep alive service isn’t actually working. There’s some docs on how to do this here https://our.umbraco.com/documentation/reference/config/Serilog/ and you could change the minimum logging level of
Umbraco.Web.Scheduling.KeepAlive
toFatal
(anything higher than Error)Azure app service itself i believe has the ability to keep alive it’s own service so we should have the ability to configure the built in one in order to just disable it.
What do you think?