How do I access admin endpoints if WireMock.Net is hosted behind AWS application load balancer? #612

Closed
opened 2025-12-29 08:30:55 +01:00 by adam · 11 comments
Owner

Originally created by @rui-ktei on GitHub (Jul 2, 2024).

Originally assigned to: @StefH on GitHub.

Hello,
Right now, all the admin paths are hardcoded as /__admin/*. But if I host this server behind AWS ALB, when I set up a listener rule, I usually specify a route prefix so that the ALB knows how to distribute traffic to the correct container. In that case, the requests coming through will all carry route prefix, say, /myprefix, and then the built-in admin endpoints will not work because /myprefix/admin/* does not exist.

Here is the code I found where admin paths are hardcoded: https://github.com/WireMock-Net/WireMock.Net/blob/master/src/WireMock.Net/Server/WireMockServer.Admin.cs

Could you tell me if what I understand so far is correct and if so, will there be any solution to it?

Thank you!

Originally created by @rui-ktei on GitHub (Jul 2, 2024). Originally assigned to: @StefH on GitHub. Hello, Right now, all the admin paths are hardcoded as `/__admin/*`. But if I host this server behind AWS ALB, when I set up a listener rule, I usually specify a route prefix so that the ALB knows how to distribute traffic to the correct container. In that case, the requests coming through will all carry route prefix, say, `/myprefix`, and then the built-in admin endpoints will not work because `/myprefix/admin/*` does not exist. Here is the code I found where admin paths are hardcoded: https://github.com/WireMock-Net/WireMock.Net/blob/master/src/WireMock.Net/Server/WireMockServer.Admin.cs Could you tell me if what I understand so far is correct and if so, will there be any solution to it? Thank you!
adam added the question label 2025-12-29 08:30:55 +01:00
adam closed this issue 2025-12-29 08:30:55 +01:00
Author
Owner

@StefH commented on GitHub (Jul 2, 2024):

@rui-ktei
Your understanding is correct.
The solution would be to replace the hardcoded admin paths with configurable admin paths. I need to look into that.

@StefH commented on GitHub (Jul 2, 2024): @rui-ktei Your understanding is correct. The solution would be to replace the hardcoded admin paths with configurable admin paths. I need to look into that.
Author
Owner

@rui-ktei commented on GitHub (Jul 2, 2024):

@rui-ktei Your understanding is correct. The solution would be to replace the hardcoded admin paths with configurable admin paths. I need to look into that.

@StefH Thank you for looking into that! Do you have a roadmap such as when you think it could be supported in the next release? The reason I'm asking is because I'm struggling to decide whether I should wait for the offical fix or fork this repository.

@rui-ktei commented on GitHub (Jul 2, 2024): > @rui-ktei Your understanding is correct. The solution would be to replace the hardcoded admin paths with configurable admin paths. I need to look into that. @StefH Thank you for looking into that! Do you have a roadmap such as when you think it could be supported in the next release? The reason I'm asking is because I'm struggling to decide whether I should wait for the offical fix or fork this repository.
Author
Owner

@luap-podium commented on GitHub (Jul 2, 2024):

Hello, Right now, all the admin paths are hardcoded as /__admin/*. But if I host this server behind AWS ALB, when I set up a listener rule, I usually specify a route prefix so that the ALB knows how to distribute traffic to the correct container. In that case, the requests coming through will all carry route prefix, say, /myprefix, and then the built-in admin endpoints will not work because /myprefix/admin/* does not exist.

Here is the code I found where admin paths are hardcoded: https://github.com/WireMock-Net/WireMock.Net/blob/master/src/WireMock.Net/Server/WireMockServer.Admin.cs

Could you tell me if what I understand so far is correct and if so, will there be any solution to it?

Thank you!

@rui-ktei I just came across the same problem today but in my case GCP LB. I was able to add a rewriteTarget: "/" to the ingress spec so the service path is matched then replaced with the slash when forwarded on.

I'm not sure if this is supported in AWS ALB these days (or something similar) but thought I'd mention if useful.

@luap-podium commented on GitHub (Jul 2, 2024): > Hello, Right now, all the admin paths are hardcoded as `/__admin/*`. But if I host this server behind AWS ALB, when I set up a listener rule, I usually specify a route prefix so that the ALB knows how to distribute traffic to the correct container. In that case, the requests coming through will all carry route prefix, say, `/myprefix`, and then the built-in admin endpoints will not work because `/myprefix/admin/*` does not exist. > > Here is the code I found where admin paths are hardcoded: https://github.com/WireMock-Net/WireMock.Net/blob/master/src/WireMock.Net/Server/WireMockServer.Admin.cs > > Could you tell me if what I understand so far is correct and if so, will there be any solution to it? > > Thank you! @rui-ktei I just came across the same problem today but in my case GCP LB. I was able to add a `rewriteTarget: "/"` to the ingress spec so the service path is matched then replaced with the slash when forwarded on. I'm not sure if this is supported in AWS ALB these days (or something similar) but thought I'd mention if useful.
Author
Owner

@StefH commented on GitHub (Jul 2, 2024):

https://github.com/WireMock-Net/WireMock.Net/pull/1130

@StefH commented on GitHub (Jul 2, 2024): https://github.com/WireMock-Net/WireMock.Net/pull/1130
Author
Owner

@StefH commented on GitHub (Jul 2, 2024):

@rui-ktei
A PR is in progress, you can take a look if you want.

And I guess you will also need a new Docker image version?

@StefH commented on GitHub (Jul 2, 2024): @rui-ktei A PR is in progress, you can take a look if you want. And I guess you will also need a new Docker image version?
Author
Owner

@rui-ktei commented on GitHub (Jul 3, 2024):

@rui-ktei
A PR is in progress, you can take a look if you want.

And I guess you will also need a new Docker image version?

@StefH Thank you so much! I use the standalone version to build my own docker image so technically I won't use the official docker image.

@rui-ktei commented on GitHub (Jul 3, 2024): > @rui-ktei > A PR is in progress, you can take a look if you want. > > And I guess you will also need a new Docker image version? @StefH Thank you so much! I use the standalone version to build my own docker image so technically I won't use the official docker image.
Author
Owner

@rui-ktei commented on GitHub (Jul 3, 2024):

@luap-podium Thank you for your comment. Unfortunately as far as I know, AWS ALB doesn't have the same feature as GCP, which seems to be a way smarter LB. But anyways, the author is very kind to open a PR to implement my feature request. I guess I'll just wait until that PR is merged.

@rui-ktei commented on GitHub (Jul 3, 2024): @luap-podium Thank you for your comment. Unfortunately as far as I know, AWS ALB doesn't have the same feature as GCP, which seems to be a way smarter LB. But anyways, the author is very kind to open a PR to implement my feature request. I guess I'll just wait until that PR is merged.
Author
Owner

@StefH commented on GitHub (Jul 3, 2024):

If you use the standalone NuGet, you can try preview 1.5.59-ci-18863 (see https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions)

An AdminPath property has been added to the WireMockServerSettings class.

@StefH commented on GitHub (Jul 3, 2024): If you use the standalone NuGet, you can try preview `1.5.59-ci-18863` (see https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions) An `AdminPath` property has been added to the **WireMockServerSettings** class.
Author
Owner

@StefH commented on GitHub (Jul 8, 2024):

@rui-ktei
Were you able to test this?

@StefH commented on GitHub (Jul 8, 2024): @rui-ktei Were you able to test this?
Author
Owner

@rui-ktei commented on GitHub (Jul 9, 2024):

@rui-ktei
Were you able to test this?

Hi, I did download the preview package and it worked fine for me. I'm just waiting for the official release now 🙂

@rui-ktei commented on GitHub (Jul 9, 2024): > @rui-ktei > Were you able to test this? Hi, I did download the preview package and it worked fine for me. I'm just waiting for the official release now 🙂
Author
Owner

@StefH commented on GitHub (Jul 9, 2024):

Good to hear.
New version will be released this afternoon.

@StefH commented on GitHub (Jul 9, 2024): Good to hear. New version will be released this afternoon.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net#612