NetTalk Central

Author Topic: Serving a static website with NT instead if IIS  (Read 4527 times)

john.farmer@absgrp.com

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Serving a static website with NT instead if IIS
« on: February 25, 2020, 07:23:31 PM »
Is it reasonable to serve a static web site (not app) with NT instead of IIS?  Would NT be more secure or is there no benefit. If so, can it serve up existing HTML files or does the content have to be embeded in code, such as example Web32?

Graham

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
Re: Serving a static website with NT instead if IIS
« Reply #1 on: February 26, 2020, 12:05:20 AM »
Hi John,

Yes.  NT will happily serve any static HTML file as is, no code required - you would simply put the file into your WEB folder.

As for security, if you are simply serving static html files from the Web folder, there's not much difference.

You could choose to "wrap" your static files into a NT NetWebPage and use NT TAGS to serve them eg. <!-- Net:f:Index.html --> (See TAGS in the NT docs)

Using this approach, you could add things like logins and other code you might like to "protect" your site

An added bonus of using NT would be the ability to serve a Secure site with Let's Encrypt certificates which are a doddle in NT...  imagine this would require a little more effort in IIS

NT - you have control, IIS - You at the mercy of MS

My 2c worth...

Regards
Graham

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11244
    • View Profile
Re: Serving a static website with NT instead if IIS
« Reply #2 on: February 26, 2020, 12:59:18 AM »
What Graham said.


john.farmer@absgrp.com

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Re: Serving a static website with NT instead if IIS
« Reply #3 on: February 28, 2020, 04:17:50 AM »
Do all images & CSS files go into the /web folder?  I tried that but the NT app is serving up just the HTML pages, without images and CSS style.  Also, I had to include index.html on the URL line.  Should that be automatic?  I started with the web32 example and removed demo  code from the WebHandler procedure but it does not automatically server index.html.

Jane

  • Sr. Member
  • ****
  • Posts: 371
  • Expert on nothing with opinions on everything.
    • View Profile
    • Email
Re: Serving a static website with NT instead if IIS
« Reply #4 on: February 28, 2020, 02:01:10 PM »
John,

You might want to compile the Pages (47) example instead. 

You'll notice on the NetWebServer extension on the WebServer procedure, on the General tab the default page is set to 'index.htm'

This example actually has some dynamic stuff (via tags) embedded into the static index.htm text file in the web folder.  And that dynamic stuff embeds scripts and CSS which you can see if you View Source in the browser.   

But that will work with a completely static html text file just as well. 

As for where the server looks for your images and CSS, that will depend on what you've got in your html text file(s). 

If you want the CSS in the webserver\web\styles folder, then you should have a link in your html page's header like
  <link href="/styles/jquery-nt-color.css?c=1" rel="stylesheet"/>

If you want it in the web folder itself, then the link should start with a forward slash and your CSS file name.

HTH,

Jane

DonRidley

  • Don Ridley
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 729
  • donaldridley2011@gmail.com
    • View Profile
    • Email
Re: Serving a static website with NT instead if IIS
« Reply #5 on: March 01, 2020, 05:24:40 AM »
Hello John,

As Jane alluded to, for your scripts, css, images, etc., you just have to ensure your link headers point to the correct location.  Here's an excerpt from one of my apps:

<link rel="manifest" href="/manifest.json" />
<link href="/themes/base/theme.css?c=1" rel="stylesheet" />
<link href="/redactor/redactor.min.css?c=1" rel="stylesheet" />
<link href="/styles/firefox.css?c=1" rel="stylesheet"/>
<script src="/scripts/all.js?c=1" type="text/javascript"></script>
<script src="/serviceworker.js" type="text/javascript"></script>
<script src="/scripts/pwa.js" type="text/javascript"></script>
<script src="/redactor/redactor.min.js?c=1" type="text/javascript"></script>
<script src="/scripts/custom.js?c=1" type="text/javascript"></script>
<script src="/scripts/jquery.timepicker.min.js?c=1" type="text/javascript"></script>

For a static site, I simply use the existing defeult NetTalk folders and adjust the static pages' headers to point to the NetTalk folders.

As Jane mentioned, by adding the tag <!-- Net:WebServer --> at the top of your static pages' html you can embed dynamically generated NetTalk pages, forms, and browses into your static content.

Come to think of it, there's liitle you cannot do with a NetTalk webserver.  It's a very powerful platform and you get the added benifit of consistant security upgrades as long as you keep your NetTalk up to date.  I guess that's why so many of us have committed to NetTalk and never looked back.

Best of luck on your project and feel free to ask for help. 


Don
"Eliminate the impossible, whatever remains, however unlikely, must be the truth."

NetTalk 12.55
Clarion 11

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11244
    • View Profile
Re: Serving a static website with NT instead if IIS
« Reply #6 on: March 01, 2020, 09:55:01 PM »
Hi John,

>> Do all images & CSS files go into the /web folder?

In it, or "under" it, yes.
It will be the same structure as it is in your IIS folder. In other words if index.html references \styles\whatever.css then the whatever css will be in your \web\styles folder.

>> I tried that but the NT app is serving up just the HTML pages, without images and CSS style.

You can use right-click, view page source, in your browser to see what files the static pages thinks it needs. Be sure to get the path right.

>> Also, I had to include index.html on the URL line.  Should that be automatic?

this is what we call the "default page" - the page that is loaded when the user does not specify a page. The default page for each site can be different. So you set this in the WebServer procedure, NetTalk Extension, Default Page setting.

Cheers
Bruce