Base solution for your next web application
Open Closed

Change Tenant login page get 404 on Azure container #7138


User avatar
0
terry21 created

I am running ASP.NetCore & Angular v6.7.0

I am able to run server and client docker containers locally using localhost:9901 and 9902 When I deploy the same containers to  Azure the application all works EXCEPT I get a 404 error (nginx/1.17.0) when I try to change the tenant on the login page (or even just enter the <span class="highlight" style="color: rgb(0, 0, 0);"><span class="colour" style="color: rgb(24, 24, 24);"><span class="font" style="color: rgb(24, 24, 24);"><span class="size" style="color: rgb(24, 24, 24);">___________</span></span></span></span>.eastus.azurecontainer.io/account/login). If I remove the "/account/login" the login page appears and yet the url in the browser location field includes the "account/login".  I am also not able to login with Active directory from the Azure version due to the 404 on the account/login redirect. The only things that I change between the two containers are the remote and host urls and the SQL server connection string.

Any ideas as to why this is happening?

Thanks...

<br> <br>


13 Answer(s)
  • User Avatar
    0
    ryancyq created
    Support Team

    Hi, can you check the details of the 404 http request in the backend?

    for example, what is the url that is requested and backend returned 404?

  • User Avatar
    0
    ismcagdas created
    Support Team
  • User Avatar
    0
    terry21 created

    If I don't even change the Tenant on the Login popup leaving it as "Default" and click "Save" button I see in Fiddler a successful server-side call to /api/services/app/Account/IsTenantAvailable followed immediately by the unsuccessful call to the http://websitename.eastus.azurecontainer.io/account/login

    in fact, if I enter the base http://websitename.eastus.azurecontainer.io the login screen appears and the "unknown' url appears in the browser url location: http://websitename.eastus.azurecontainer.io/account/login If I just move my cursor up to the browser url location and press Enter I get the same 404 error

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @terry21

    Does your published Angular app contains a web.config ? If so, could you share its content ?

  • User Avatar
    0
    terry21 created

    The angular app did not contain a web.config on my local or Azure container. I just added the web.config from my development environment that came with the AspNetZero template into the Azure container (asset folder) and published it into Azure, restarted the app, but it didn't make a difference.

    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <system.webServer>
        <staticContent>
          <remove fileExtension=".json" />
          <mimeMap fileExtension=".json" mimeType="application/json" />
    	  <mimeMap fileExtension="woff" mimeType="application/font-woff" />
          <mimeMap fileExtension="woff2" mimeType="application/font-woff" /> 
        </staticContent>
        <!-- IIS URL Rewrite for Angular routes -->
        <rewrite>
          <rules>
            <rule name="Angular Routes" stopProcessing="true">
              <match url=".*" />
              <conditions logicalGrouping="MatchAll">
                <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                <add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />
              </conditions>
              <action type="Rewrite" url="/" />
            </rule>
          </rules>
        </rewrite>
      </system.webServer>
    </configuration>
    
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @terry21

    Sorry for my late reply. Could you share url of your app with [email protected] for us to check this problem ?

    Thanks,

  • User Avatar
    1
    terry21 created

    I’m pretty sure it is an issue with the Url Rewrite – thanks for suggesting it. In a Linux container the web server is NGINX so the Url Rewrite has to be configured in the nginx.conf file not the web.config like for IIS I see the nginx.conf file got uploaded correctly on my local docker container which is why it is working. The file did not upload properly for the Azure container and, as a result, the Url rewrite does not work.

    I now need to figure out how to load the nginx.conf file into the Azure Linux angular container.

    Thanks,

  • User Avatar
    0
    venkat created

    Hi Everyone,

    Even we are facing same issue.... is there any resolution for this?

    Thank you

  • User Avatar
    0
    ismcagdas created
    Support Team

    You can check https://www.nginx.com/blog/creating-nginx-rewrite-rules/ to see how to write a rewrite rule for Nginx.

  • User Avatar
    0
    terry21 created

    Thank you but the nginx.conf file that rewrites the URL properly as it is working fine in my local docker container. The issue is with Azure not properly updating the nginx.conf file. Based on this, I realize this is beyond the expected support of AspNetZero support.

    THat beiing said, has anyone encountered this error and figured out how to resolve it?

  • User Avatar
    0
    venkat created

    Thank you @terry21 @ismcagdas, Azure Linux webapp uses .htaccess (instead nginx.conf) for url rewrites. I hope AspNetZero can provide us a .htaccess file for hosting agular version on Azure.

    Thank you

  • User Avatar
    0
    terry21 created

    hello @venkat Azure Linux can use Apache as its webserver and then it will use use .htaccess. In my case I am using Azure Linux with an nginx webserver so it will use the nginx.conf .

    When I look within the Azure container instance I do see an nginx.conf file but it is not the one I uploaded as part of my container as was the case in my local docker container. The Azure nginx.conf seems to have its own that possiby is not updateable. The nginx.conf does have a line at the end to extend to a /etc/nginx/conf.d/*.conf

    In the /etc/nginx/conf.d folder there is a default.conf that may be were I am suppoed to put my redirects and should be getting executed with the base nginx.conf. I have tried manually updating the default.conf file in the instance and restarting but still no luck.

    I will try submitting this issue to an Azure forum as it is not really a problem specific to AspNetZero.

  • User Avatar
    0
    venkat created

    Thanks @terry21, so I guess we both running into same issue but on different environments.

    If anyone has .htaccess file which will work with AspNetZero Angular please share it.

    Thank you