[GH-ISSUE #6] Error 404 when trying to open the acme challenge url #4

Closed
opened 2026-02-26 21:31:03 +03:00 by kerem · 1 comment
Owner

Originally created by @petrnejedly on GitHub (Jan 14, 2018).
Original GitHub issue: https://github.com/ridercz/AutoACME/issues/6

Hi,

Let's say I own a domain "site.eu". In my IIS there are (among others) two separate WebSites:

  • SiteEuWww (D:\WebSites\SiteEu\www)
  • SiteEuNoWww (D:\WebSites\SiteEu\nowww)

The www directory is the root directory of my website. The nowww directory contains only a Web.Config file managing 301 redirects from no-www to www (<httpRedirect enabled="true" destination="https://www.site.eu" httpResponseStatus="Permanent" />). The site already uses a paid SSL certificate and I want to switch to Let's encrypt now.

Bindigs are set as follows:

When I try to request for a new certificate file (autoacme addhost www.site.eu) for the first time, the attempt to open an url address http://www.site.eu/.well-known/acme-challenge/ ends up with an error 404. I think that the url http://www.site.eu/.well-known/acme-challenge/ redirects to https://www.site.eu/.well-known/acme-challenge/ and now the error 404 occurs. I think the request does not go through the Url Rewrite module in IIS at this case.

Is there anything I can do to make it work in this scenario?

Originally created by @petrnejedly on GitHub (Jan 14, 2018). Original GitHub issue: https://github.com/ridercz/AutoACME/issues/6 Hi, Let's say I own a domain "site.eu". In my IIS there are (among others) two separate WebSites: - SiteEuWww (D:\WebSites\SiteEu\www) - SiteEuNoWww (D:\WebSites\SiteEu\nowww) The www directory is the root directory of my website. The nowww directory contains only a Web.Config file managing 301 redirects from no-www to www (```<httpRedirect enabled="true" destination="https://www.site.eu" httpResponseStatus="Permanent" />```). The site already uses a paid SSL certificate and I want to switch to Let's encrypt now. Bindigs are set as follows: - https://www.site.eu/ ==> SiteEuWww (website content) - http://www.site.eu/ ==> SiteEuNoWww (301 redirect to https://www.site.eu/) - http://site.eu/ ==> SiteEuNoWww (301 redirect to https://www.site.eu/) - https://site.eu/ ==> SiteEuNoWww (301 redirect to https://www.site.eu/) When I try to request for a new certificate file (```autoacme addhost www.site.eu```) for the first time, the attempt to open an url address *http://www.site.eu/.well-known/acme-challenge/<ticket-id>* ends up with an error 404. I think that the url *http://www.site.eu/.well-known/acme-challenge/<ticket-id>* redirects to *https://www.site.eu/.well-known/acme-challenge/<ticket-id>* and now the error 404 occurs. I think the request does not go through the *Url Rewrite* module in IIS at this case. Is there anything I can do to make it work in this scenario?
kerem closed this issue 2026-02-26 21:31:03 +03:00
Author
Owner

@ridercz commented on GitHub (Jan 14, 2018):

Your setup is quite unusual and I believe also needlessly complicated.

HTTP-01 challenge follows redirects. I believe you are redirecting to wrong address, ie. you are always redirecting to root URL, not the URL that was asked for.

I recommend you to create single site, which would have four bindings:

  • http://www.site.eu/
  • http://site.eu/
  • https://www.site.eu
  • https://site.eu/

Then use URL rewriting to redirect to the canonical address (www.site.eu) and HTTPS:

<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="CanonicalHostName" stopProcessing="true" enabled="false">
          <match url="(.*)" />
          <conditions>
            <add input="{HTTP_HOST}" pattern="^www\.site\.eu$" negate="true" />
          </conditions>
          <action type="Redirect" url="https://www.site.eu/{R:1}" redirectType="Permanent" />
        </rule>
      </rules>
      <rule name="ForceHTTPS" stopProcessing="true" enabled="true">
        <match url="(.*)" />
        <conditions>
          <add input="{HTTPS}" pattern="^OFF$" />
        </conditions>
        <action type="Redirect" url="https://www.site.eu/{R:1}" redirectType="Permanent" />
      </rule>
    </rewrite>
  </system.webServer>
</configuration>

This redirect will retain the part of URL after host name and therefore everything will work correctly. AutoACME will then be able to get certs for both site.eu and www.site.eu.

<!-- gh-comment-id:357520023 --> @ridercz commented on GitHub (Jan 14, 2018): Your setup is quite unusual and I believe also needlessly complicated. HTTP-01 challenge follows redirects. I believe you are redirecting to wrong address, ie. you are always redirecting to root URL, not the URL that was asked for. I recommend you to create single site, which would have four bindings: * `http://www.site.eu/` * `http://site.eu/` * `https://www.site.eu` * `https://site.eu/` Then use URL rewriting to redirect to the canonical address (`www.site.eu`) and HTTPS: ``` <configuration> <system.webServer> <rewrite> <rules> <rule name="CanonicalHostName" stopProcessing="true" enabled="false"> <match url="(.*)" /> <conditions> <add input="{HTTP_HOST}" pattern="^www\.site\.eu$" negate="true" /> </conditions> <action type="Redirect" url="https://www.site.eu/{R:1}" redirectType="Permanent" /> </rule> </rules> <rule name="ForceHTTPS" stopProcessing="true" enabled="true"> <match url="(.*)" /> <conditions> <add input="{HTTPS}" pattern="^OFF$" /> </conditions> <action type="Redirect" url="https://www.site.eu/{R:1}" redirectType="Permanent" /> </rule> </rewrite> </system.webServer> </configuration> ``` This redirect will retain the part of URL after host name and therefore everything will work correctly. AutoACME will then be able to get certs for both `site.eu` and `www.site.eu`.
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/AutoACME#4
No description provided.