Skip to content

Web server and framework for web development based on Kestrel from Microsoft ASP.NET with support for plugins and modules.

License

Notifications You must be signed in to change notification settings

jpdante/HtcSharp

Repository files navigation

HTCSharp

Web server for application development, based on the Asp.Net Kestrel but not using the Asp.Net Framework as the basis for the server.

Why use it ?

The HtcSharp project aims not to get the developer into how AspNet works by trying to be as minimal as possible, such as HttpListener but allowing some of AspNet's features to be used.

Why was this project developed ?

When trying to work with Asp Net I felt very stuck the way the framework works and processes requests, the truth is that I prefer the low level of HttpListener, but this is a legacy technology that does not support encryption, so there was a need to use an Http Protocol with encryption support.

The project's attempt is to make it look like the Nginx server by configuration, and allow the implementation of plugins and modules. The modularity of the project allows multiple modules to be implemented by simply adding a library. And plugins allow scripts like Lua and PHP to be executed to render pages.

This also allows one part of the code to be executed in CSharp and the other part in a scripting language like Lua, so the page is rendered by Lua while the database, algorithms and others are executed in CSharp.

The future of the project and what I expect from it

It all started just as a personal project to allow me to develop my sites more easily, the viability of the project for commercial or normal use is still very low, as I still consider it in Alpha. Despite the use of Asp Net, this technology does not please me since I have to reprocess all requests, besides it seems slow by itself, so I am creating my own http server that would eliminate dependence on Asp Net but it may take some time until it is finished.

Getting Started

To use this program you must have .Net Core 3.1 installed, in the future self-contained releases will be published.

Prerequisites

Prerequisites for compiling plugins:

Installation

For now the only way to install is to download the repository and compile the solution, in the future binary versions will be released.

Usage

Console mode for Linux, Windows and Mac

dotnet <path>/HtcSharp.Server.dll <optional args>

Daemon Service Mode for Linux

dotnet <path>/HtcSharp.Server.dll daemon-mode

Optional Args

  • daemon-mode - Force the server to run in daemon mode by disabling console input (It is strictly necessary if used as a service in linux as in systemd).
  • "../HtcConfig.json" - Specifies the path where the server can get the configuration file.

Configuration

I tried my best to make the configuration look like Nginx, so I think it's easy for those who already know about it.

Example Configuration:

{
    "ModulesPath": "%WorkingPath%\\modules\\",
    "PluginsPath": "%WorkingPath%\\plugins\\",
    "Engines": {
        "htc-http": {
            "Servers": [
                {
                   "Hosts":[
                      "0.0.0.0:8080"
                   ],
                   "Domains":[
                      "*"
                   ],
                   "Default":[
                      "try_pages $uri",
                      "try_files $uri",
                      "index $internal_indexes",
                      "autoindex on",
                      "return 404"
                   ],
                   "Root":"%WorkingPath%/www/",
                   "SSL":false
                },
                {
                   "Hosts":[
                      "0.0.0.0:8443"
                   ],
                   "Domains":[
                      "sub.mydomain.com",
                      "mydomain.com"
                   ],
                   "Default":[
                      "try_pages $uri",
                      "try_files $uri",
                      "index $internal_indexes",
                      "autoindex on",
                      "return 404"
                   ],
                   "Root":"%WorkingPath%/www/",
                   "SSL":true,
                   "Certificate": "%WorkingPath%/ssl/mydomain.com.pfx",
                   "Password": "Cert Password"
                }
             ]
        }
    }
}

Wiki

See the wiki for more information on how to use it.

Roadmap

See the open issues for a list of proposed features (and known issues).

License

Distributed under the Apache-2.0 License. See LICENSE for more information.

About

Web server and framework for web development based on Kestrel from Microsoft ASP.NET with support for plugins and modules.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published