I have a static file, letsencrypt.txt, in the wwwroot folder on my website.
But going to http://{domain}.com/letsencrypt.txt gives 404.
This is not on a virtual machine, shared or otherwise. I do not have root access or CPanel access. I do not have any extra Azure Storage.
I do have a Subscription, a Resource Group, an App Service, an App Service Plan, and an API Management Service. I do have FTP access, so I can see the file structure and upload files and download log files.
In practice, all I really know is that the file is at /site/wwwroot.
The log shows
<tr class="alt"><th>Requested URL</th><td>https://{domain}:80/letsencrypt.txt</td></tr>
<tr><th>Physical Path</th><td>**C:\home\site\wwwroot\letsencrypt.txt**</td></tr>
which is exactly where I think the file is located.
I can't see any reason for it to not be able to find the file.
Nothing in the log about access control or permissions.
I thought that perhaps the https issue was a result of the DNS redirect, but I get the same 404 if I go directly to {domain}.azurewebsites.net. And it still redirects to https.
One interesting point is that, here in the log, it specifies port 80 even though it says https.
Here is the entire web.config.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\SmartTagsAPI.dll" stdoutLogEnabled="false" stdoutLogFile="\\?\%home%\LogFiles\stdout" hostingModel="inprocess" />
<rewrite>
<rules>
<!-- <rule name="wildcard">
<match url=".*well-known/acme-challenge/(?!.*?\.txt$)(.*)$" />
<action type="Redirect" url="LetsEncrypt/letsencrypt.txt" />
</rule> -->
</rules>
</rewrite>
</system.webServer>
</location>
</configuration>
As you revealed more information, this question becomes more like "how to set up free certificates for Azure App Service D1 plan".
D1 does not support custom SSL binding, which is by design. So, Let's Encrypt won't work either, as even if you find a way to generate the certificate, you cannot install it to D1 plan.
Like you tested, you can alternatively set up a service like Cloudflare in front which offers you free certificates.
Related
My requirement is simple.
I already have an one azure app service (https://<app_service>.azurewebsites.net/) and I hosted a NodeJs Web API app under that above mentioned app service. It worked fine when calling the API with specified app service URL(https://<app_service>.azurewebsites.net/).
My virtual path and physical path of the application is like in below image.
And this is my NodeJS web API app web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<webSocket enabled="false" />
<handlers>
<add name="iisnode" path="index.js" verb="*" modules="iisnode"/>
</handlers>
<rewrite>
<rules>
<rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^index.js\/debug[\/]?" />
</rule>
<rule name="StaticContent">
<action type="Rewrite" url="public{REQUEST_URI}"/>
</rule>
<rule name="DynamicContent">
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/>
</conditions>
<action type="Rewrite" url="index.js"/>
</rule>
</rules>
</rewrite>
<security>
<requestFiltering>
<hiddenSegments>
<remove segment="bin"/>
</hiddenSegments>
</requestFiltering>
</security>
<httpErrors existingResponse="PassThrough" />
</system.webServer>
And this is my NodeJS web API app index.js
var express = require("express");
var app = express();
app.get("/", function(req, res) {
res.send("Call from Node API!!!");
});
var port = process.env.PORT || 1660;
var server = app.listen(port, function () {
console.log("Listening on port %s...", server.address().port);
});
Now, I want this same NodeJS Web API application with another virtual path with same azure app service.
For e.g.,
(https://<app_service>.azurewebsites.net/nodeapi)
Is this possible to achieve? If so, could you please tell me how to achieve this.
Thanks in advance!
It is possible to deploy Multiple Web Apps under same App service by using Import Profile and Adding Virtual Directories in Azure Portal
Check the below workaround
Created an App service with Runtime stack Node.
In the newly created app service add the virtual applications under Configuration => Path Mappings Section
In the Overview Section of the App service, click on Get Publish Profile
In Visual Studio created two NodeJS Web Applications
Right click on the first web app and click on publish
Browse and select the PUBLISHSETTINGS file downloaded from Azure Web App from portal.
Make sure that you are giving the site name as same. Here it is NodeSample.
Check and verify the name in both places (Virtual Applications and directories in Path Mappings and in Publish Settings) are same.
Save and Publish the App.
Now select the second Web App and Continue the same steps to publish using Import Profile.
Deployed Web Apps folder structure
In this case Both the Apps are accessible by using the below URL's
Ex:
https://nodesample.azurewebsites.net/NodejsSample1
https://nodesample.azurewebsites.net/NodejsSample2
Problem #1: I have a classic cloud service running a single web site role. I would like to differentiate between the way it is debugged locally versus how it is deployed to the cloud. Specifically I would like the local site to run on HTTP and the cloud service to run on HTTPS. The main reason for this is that we don't want to have to install the same cert on all the developers' machines. However, the endpoints are defined in the common "ServiceDefinition.csdef", NOT in the two "ServiceConfiguration.cscfg" files ("local" and "cloud"). So, how do I set up different endpoints for local versus cloud?
Problem #2: I would like, especially in the cloud, to have a site running on HTTP that simply redirects the user to the HTTPS site. How would I set that up?
I realize these questions may not have sufficient detail, but I didn't want to write a book. Please feel free to ask for clarification.
Thanks a lot in advance!
Partial answer to your questions:
Problem #2: I would like, especially in the cloud, to have a site
running on HTTP that simply redirects the user to the HTTPS site. How
would I set that up?
For this, you can simply rely on web.config transforms. In your web.release.config you can set a redirection rule which will redirect http requests to https. Something like the following:
<rewrite>
<rules>
<rule name="HTTP/S to HTTPS Redirect" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{SERVER_NAME}/{R:1}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
Similar thing would just not be present in your web.debug.config (or web.config).
Specifically I would like the local site to run on HTTP and the cloud
service to run on HTTPS.
For this, the way I have handled it in the past when I worked on Cloud Services is basically I created separate cloud projects for each environment (WebApp.Azure.Dev, WebApp.Azure.Prod etc.). This way I would get separate csdef file for each environment.
I am new to Azure and currently host my node.js backend at another cloud provider, and I want to understand the steps I need to make in order to host it at Azure, without using Visual Studio Code.
It is a very easy question, yet it seems impossible to find an answer to.
I've seen the 5mins quick starts here;
https://learn.microsoft.com/en-us/azure/app-service/app-service-web-get-started-nodejs
But in the guide, the site is directly deployed to the web URL;
https://learn.microsoft.com/en-us/azure/app-service/app-service-web-get-started-nodejs#browse-to-the-app
But none of them explains the fundamentals on how Azure runs the process.
How does Azure start my backend app? Where do I configure that, what is needed?
That's not mentioned in the guide at all.
Is there a guide for what exactly what files are required and how to configure them in order to start my backend?
Microsoft Azure feels like a black box right now, any documentation is much appreciated!
As I know, you need to configure web.config if you want to run nodejs app on the Azure.
I followed this sample node.js app: nodejs-docs-hello-world and deploy it to Azure. It works fine,you could refer to web.config file:
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation batch="false" />
</system.web>
<system.webServer>
<handlers>
<add name="iisnode" path="scripts.js" verb="*" modules="iisnode" />
</handlers>
<rewrite>
<rules>
<rule name="myapp">
<match url="/*" />
<action type="Rewrite" url="scripts.js" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
I suggest you navigating to the KUDU url: https://<your app name>.scm.azurewebsites.net/DebugConsole and go to site\wwwroot to upload your files so that the files are contained within a directory.
Or discard zip deploy temporarily, just drag the local files directly to the d:home\site\wwwroot directory.
I am trying to deploy an Azure App Service from Visual Studio 15.2. Specifically I am trying to deploy this following service: https://github.com/Microsoft/Azure-SQL-DB-auditing-OMS-integration to ingest audit logs from SQL Data Warehouse to OMS. However, due to security concerns, we would like to do so without creating a public endpoint, a url. We have tried configuring it in a VNet but it does not allow you to do so unless the VNet has a public gateway.
Configure Azure App Service without public URL
As far as I know, we couldn't configure Azure App Service without public URL. If you created a web app, it will auto provide public endpoint for user to access.
Here are two work around.
I found the github application just use the web app's webjobs.
One way:
If you don't need any web site, just use the backgourd process to run the webjobs, you could choose azure function which uses WebJobs SDK itself but doesn't require an App Service to be configured for it.
Second way:
Normally we run WebJobs in a Azure App Service web app, and that Azure App Service web app can be accessed/browsed via URL. If you want to prevent users from browsing to that Azure App Service web app, you can add a rewrite rule to site’s web.config to block web access.
The web.config is like this:
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
https://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Block unauthorized traffic to staging sites" stopProcessing="true">
<match url=".*" />
<conditions>
<!-- Enter your staging site host name here as the pattern-->
<add input="{HTTP_HOST}" pattern=".*" />
<!-- Enter your white listed IP addresses -->
<add input="{REMOTE_ADDR}" pattern="123\.123\.123\.1" negate="true"/>
<!-- Add the white listed IP addresses with a new condition as seen below -->
<!-- <add input="{REMOTE_ADDR}" pattern="123\.123\.123\.2" negate="true"/> -->
</conditions>
<action type="CustomResponse" statusCode="403" statusReason="Forbidden"
statusDescription="Site is not accessible" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
More details about how to add the web.config to your web app, you could follow this steps:
1.Open kudu tool in web portal.
2.Open cmd console and locate the \site\wwwroot folder.
3.Create web.config and copy the settings in it.
4.When we accessed the web site, you could find this:
I have two different applications which I want to deploy on the same Azure WebApp like this:
webapp.azurewebsites.net/api/ <-- run the Java REST API here
webapp.azurewebsites.net/site/ <- put the Angular2 app here
Problem
Both apps are deployed on the server but currently I'm only able to get the REST API running with a web.config like this:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Force HTTPS" enabled="true">
<match url="(.*)" ignoreCase="false"/>
<conditions>
<add input="{HTTPS}" pattern="off"/>
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent"/>
</rule>
</rules>
</rewrite>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
</handlers>
<httpPlatform processPath="%JAVA_HOME%\bin\java.exe"
arguments="-jar D:\home\site\wwwroot\webapps\rest-api.war">
</httpPlatform>
</system.webServer>
</configuration>
but I'm not able to reach the Angular2 app on the server and I can't find documentation how I would configure the Java application and the Angular2 app at the same time.
I also tried to achieve this with the Virtual applications and directories settings from the Azure dashboard under Application settings - but it didn't work and I can't find a decent documentation of how I would achieve this, or if this is even possible with setting the Virtual applications and directories.
I tried to move the Angular2 site around but was not able to configure the server so that the Angular2 app is accessible while the Java application is running.
Question
Can someone point me to a good documentation on how to achieve this, or describe the deployment process in detail (with regard to the configs, e.g. the Application settings from the Azure Dashboard and the web.config file)?
Per my experience, I think the best way for deploying multiple Apps on Azure WebApps is to set the Virtual applications and directories of Application Settings for your Azure Webapp, please see the figure below.
As reference, please refer to the answer of the SO thread Add virtual directory to existing website on Azure.
Virtual Directories are supported for Azure Websites. See Configuring Azure Websites for what you can do through the Azure Management Portal. From the Azure Portal, click on the Website and go to Configure, then scroll down to virtual applications and directories (the last config section). Just enter your virtual directory and the physical path relative to the site root and click Save.
Regarding the second part of your answer, when investigating the subject I found this blog post to be the best explanation of how the Application Settings from the dashboard interact with the Web.config file:
https://azure.microsoft.com/en-us/blog/windows-azure-web-sites-how-application-strings-and-connection-strings-work/
In particular -
If the application setting(s) happen to already exist in your web.config file, Windows Azure Web Sites will automatically override them at runtime using the values associated with your website.
So the Application Settings tab in the Azure portal will take precedence over your web.config values.