How to install Ghost inside an existing node.js application on Azure? - node.js

Can you install Ghost (http://ghost.org) so that it runs inside an existing node.js express application (like this: {my domain}/blog)?
I'm using Azure Websites to host the site.
Please note: I would prefer a generic solution that can run on any platform... however I thought I would mention that it's on Azure in case it provides a simple way to do this.

Yes you can do that.
You will need to:
1. Add a new blog application
Basically go to portal -> CONFIGURE tab -> scroll all the way to the bottom and add something like this
2. Configure Ghost to run on a sub folder
publish Ghost to whichever folder you mapped to your application in the step above.
You can use FTP, webdeploy or SCM (https://<YouSiteName>.scm.azurewebsites.net/DebugConsole
that's what I choose and my folder layout looks like this
igonre the deployments folder, it's not related to this
in your config.js for Ghost, under the Production environment node make sure you have the url as
production: {
url: 'http://<YourSiteName>.azurewebsites.net/blog',
mail: {
......
}
}
3. Fix the main site's web.config
go to your main sites web.config and wrap the whole <system.webServer> element in a <location path="." inheritInChildApplications="false">
basically your web.config should have looked like this
<configuration>
<system.webServer>
<handlers>
<add name="iisnode" path="server.js" verb="*" modules="iisnode"/>
</handlers>
<rewrite>
<rules>
<!-- Some rewrite rules -->
</rules>
</rewrite>
....
</system.webServer>
</configuration>
and now it should look like this
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="iisnode" path="server.js" verb="*" modules="iisnode"/>
</handlers>
<rewrite>
<rules>
<!-- Some rewrite rules -->
</rules>
</rewrite>
....
</system.webServer>
</location>
</configuration>
notice this is for the main site that is the Express.js in your case not the Ghost site
that should be all you need to do.

Not sure if you can install it as an addition to your existing site, but Ghost exists as a deployable template in the Azure Web Sites gallery, under Blogs:

This is not the complete answer you were looking for, but these instructions on how to manually install Ghost on Azure Websites might help guide you in the right direction:
http://www.hanselman.com/blog/HowToInstallTheNodejsGhostBloggingSoftwareOnAzureWebsites.aspx

Related

Web.config setup for IIS development

I am running an IIS instance (Not the default IIS Express) on which I have configured my ASP.NET Core 3.1 MVC project.
I would like to configure my web.config file, so that I have the following behavior:
Each time i update a view (.cshtml file) in my solution, the update is instantly visible after i refresh the page.
Each time i update a controller or a model (.cs file) the update becomes visible after a rebuild of the solution.
What I currently have is the following configuration in my root directory:
<?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=".\bin\Debug\netcoreapp3.1\Live.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
</system.webServer>
</location>
</configuration>
Now with the following configuration I have to rebuild each time I want to see the result of my modifications. There's also another problem, each time I rebuild the app I encounter the following problem:
1>D:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(4502,5): error MSB3021: Unable to copy file "obj\Debug\netcoreapp3.1\Live.dll" to "bin\Debug\netcoreapp3.1\Live.dll". The process cannot access the file 'bin\Debug\netcoreapp3.1\Live.dll' because it is being used by another process.
I have to manually stop the IIS instance and then rebuild my solution.
I have worked on a project where this was the way things were done, however I never figured out how it was configured. I would appreciate any help if possible, Thanks.

Azure vue issuse with missing server.js/app.js?

I am new to web development and I have tried to upload my vue app to a azure web app service but i am getting some problems
so when I try to try to open the webpage up it says
"You do not have permission to view this directory or page."
I have been trying to follow a few guide about a web.config file, and when i added it, the message disappered, but now it shows nothing. Then i tried to take a look at my output when i try to upload my code, here it says
missing server.js/app.js
my app file is a vue file, but i don´t really know how to fix this, it´s also not located at the root but in a src folder
i added the web config file to the public folder
<configuration>
<system.webServer>
<!-- indicates that the index.js file is a node.js application
to be handled by the iisnode module -->
<handlers>
<add name="iisnode" path="index.js" verb="*" modules="iisnode" />
</handlers>
<!-- adds index.js to the default document list to allow
URLs that only specify the application root location,
e.g. http://mysite.antarescloud.com/ -->
<defaultDocument enabled="true">
<files>
<add value="index.js" />
</files>
</defaultDocument>
</system.webServer>
</configuration>

.NET Core WebAPI IIS Deploying

I have created a webAPI using .Net Core and trying to publish it to IIS. But getting HTTP 500.19.
It's looking for web.config file but I don't have it.
What should I do?
Did you installed this: https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/?tabs=aspnetcore2x&view=aspnetcore-3.1
If Yes check your permissions on the folder. The identity under which your web application runs in IIS may has not full access to the folder in which the web.config file is found. You could change your identity under the appPool or grant access to your folder. If you deployed into the wwwroot folder the IUser should have access to the folder.
When you publish your .net core in IIS please remember to install .net core web hosting bundle because it is not supported by default. IIS handle request based on different handlers. Even when you install the extension, aspnet core module is not registered. So please remember to set
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" requireAccess="Script" />
</handlers>
<aspNetCore processPath=".\myapp.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="InProcess" />
</system.webServer>
</location>
</configuration>
If the solution doesn't fix this. Then something in your web.config is corrupting the application. Please post a screenshot the detailed error message. Then we would know how to fix this completely.

How to provide an .exe file as download on Windows Azure Website?

I am trying to publish a ClickOnce installer onto a website which is hosted on Windows Azure. The publishing process works as expected, nontheless the setup file is not available for download via HTTP. Obviously it is not possible to provide executables (.exe) and libraries (.dll) via HTTP. They are available via FTP, but HTTP requests yield a 'File not found' (404). After renaming the file to setup.txt, it can be downloaded, this doesn't really help, though. Can this be configured somehow?
Please try by adding the following in your web.config file:
<system.webServer>
<handlers>
<add name="Client exe" path="*.exe" verb="*" modules="StaticFileModule" resourceType="File" />
</handlers>
</system.webServer>
Source: http://mike-ward.net/blog/post/00631/how-to-configure-iis-7-to-allow-downloading-exe-files.
Add the allowed mime type to web config. Eg:
<system.webServer>
<staticContent>
<mimeMap fileExtension=".exe" mimeType="application/exe"/>
</staticContent>
</system.webServer>

What is the proper syntax for relative paths in web.config?

I have a site structure like this:
And I'd like to use a relative path to my test_isapi.dll in the web.config for the ISAPI application. I've tried replacing C:\TestSite1\TestSite2\ISAPI\test_isapi.dll with the following relative paths with no luck:
test_isapi.dll
~/test_isapi.dll
~\test_isapi.dll
ISAPI\test_isapi.dll
Do I have the syntax wrong for the relative path, or is this just not possible for handler settings in the config?
Current (working with absolute path) web.config (TestSite1/TestSite2/ISAPI/web.config):
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="Test ISAPI"
path="*"
verb="*"
modules="IsapiModule"
scriptProcessor="C:\TestSite1\TestSite2\ISAPI\test_isapi.dll"
resourceType="Unspecified"
requireAccess="None"
preCondition="bitness32" />
</handlers>
</system.webServer>
</configuration>
My solution was to programmatically check and add the handler mapping instead of deploying the setting with the web.config. That way I can determine the absolute path at run-time and apply the setting. Not ideal, but it gets the job done.
See this answer: How to add IIS handler mapping programmattically
config you can write ~/filepath
To use a relative path just Add ~/test_isapi.dll for ISAPI Site webconfig.

Resources