jmalarcon / MIIS

Powerful file-based CMS for IIS - Your Markdown-based documentation or website in a few minutes!
https://miis.azurewebsites.net/
MIT License
31 stars 6 forks source link

IIS server requirements #33

Closed tschertel closed 2 years ago

tschertel commented 2 years ago

Could you please provide further information on how to host MIIS on an IIS Server (not IIS Express)?

I'm not sure what are the basic requirements, but I couldn't make it run (error 500.19).

This problem occurs because the ApplicationHost.config or Web.config file contains a malformed or unidentified XML element. IIS can't identify the XML elements of the modules that are not installed. For example, IIS URL Rewrite module.

jmalarcon commented 2 years ago

Hi:

It'll run in any modern IIS version (IIS 7.0 or later) and you need to have .NET framework 4.5+ installed (is installed by default in Windows Server 2012 or later: anyway I won't recommend using such an old system unless it's unavoidable).

In IIS, set the App Pool for your application to use .NET 4.x and the integrated pipeline, like this:

image

That's it.

HTH

tschertel commented 2 years ago

That's exactly what I have here. But I still get the 500.19 error

image

image

Edit: When I try to open any option from IIS application, I get this error: image image

jmalarcon commented 2 years ago

Hi again:

It's an error in the configuration. There's another requirement I totally forgot to mention in my previous message that probably has something to do with this because it is in the default web.config file: the URL Rewrite module. This is needed in order to remove the .md extension of the files if written directly, and other small details.

Please, install this extension (which is really useful anyway: I always have it installed in all my servers), or remove the <rewrite> section of the web.config.

Sorry about that. I'll update the readme to add this requirement.

Please, check all the examples in the /src/Tests folder to see all the powerful features MIIS has.

And tell me if this fixes your issue. Thanks,

tschertel commented 2 years ago

Hi José... After URL rewrite installing, I got a "plain" error 500. Then I tried your tip of using the src folder as my root folder Now I get an error complaining about the handlers:

image

I'm trying MIIS in a fresh Windows 2022 install. Thanks for your help.

jmalarcon commented 2 years ago

Honestly I don't know what is happening to you. It should be as easy as creating the virtual server and that's it 🤔

If you have installed the URL Rewrite handler the error you're getting doesn't make sense either. It says it doesn't recognize that section, and that's exactly what URL Rewrite does.

I must say that I've not installed MIIS in a Windows Server 2022 yet, but I've installed it many times in 2012, 2016 and 2019, and in Azure without any glitch...

I'll try to install it on a Windows Server 2022 and see if there's something weird.

I think it must be a really simple setting somewhere that you're missing... Please, keep me updated. Thanks.

tschertel commented 2 years ago

Just tried the same procedure in a Windows Server 2019 with same "handlers" error. That's what I did:

I agree with you. It must be something silly to solve. Although, I'm not finding it.

jmalarcon commented 2 years ago

Hi again @tschertel

I've recorded a video showing the whole process from a freshly installed server to a working MIIS app in Windows Server 2022. Please, review the steps carefully to see what is missing in your case but, as expected, it worked at the first attempt:

https://share.getcloudapp.com/Z4u7glOR

I think this video will be very useful for some other people in the future, si I've added it to the readme file of the repo.

Please, tell me what was happening in your case. Thanks.

HTH

tschertel commented 2 years ago

Hi @jmalarcon

Now it finally works. ASP.NET 4.8 was missing. Sorry, but I didn't see any reference to it in your documentation. You say just ".NET Framework 4.5". Maybe this is not in your scope, but would be nice to have AD integration, so we could implement login with access management. This feature would be really nice to create intranets and wikis.

jmalarcon commented 2 years ago

Hi again:

It was my fault for assuming everyone that manages an IIS server would know that they need to add ASP.NET 4.x for it to work (this is something needed for any .NET 4.x web app, not only MIIS). I'll add a more explicit note.

Regarding the AD integration, this is something already present in ASP.NET, and I don't need to add anything to MIIS to support it. You can easily add support for Azure AD or for OAuth Credentials that will allow you to authenticate people using Microsoft, Google Facebook... accounts..

If you host the app in an Azure Web App is even easier: just activate the desired providers in the "Authentication" section of the Web App and you automatically get the corresponding identity in MIIS and you can control access using the conventional <authorization> nodes in web.config. Is straightforward in this case.

In MIIS there's are several automatic fields in any page or template to manage authentication You can see them in the well-known-fields.md sample file in the Tests folder of this repo (case insensitive):

Some examples:

Current user: {{username | default: "Anonymous" }} ({{authTYPE | default: "Non authenticated"}})

that will show the current user name or "Anonymous" if there's not one authenticated yet, and the type of authentication used between parenthesis.

{% if isAuthenticated %}
<div class="button">
  <a style="padding-top:1em;" href="/.auth/logout?post_logout_redirect_uri=/" title="Log out">
    <img src="/Images/logout.png">
  </a>
  ({{username}})
</div>
{% endif %}

Shows a Log out button image that sends to Azure Authentication well known point to logout the current user if there's one already authenticated (you can use {% if username != "" %} at the beginning too).

Hope this helps.