{"id":20950678,"url":"https://github.com/suglasp/pwsh_multithreaded_webserver","last_synced_at":"2026-05-18T21:04:28.263Z","repository":{"id":143368188,"uuid":"309465840","full_name":"suglasp/pwsh_multithreaded_webserver","owner":"suglasp","description":"Scalable webserver in Powershell. Uses Nginx for loadbalancing and Powershell as backend webserver that supports modules and basic inline html Powershell scripting.","archived":false,"fork":false,"pushed_at":"2021-02-05T13:43:25.000Z","size":149,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-19T22:41:52.079Z","etag":null,"topics":["http","https","loadbalancer","multithreaded","powershell","pwsh","scalable","webserver"],"latest_commit_sha":null,"homepage":"","language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/suglasp.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-02T18:52:47.000Z","updated_at":"2023-05-01T02:16:22.000Z","dependencies_parsed_at":null,"dependency_job_id":"ac7aeeeb-a7f3-46c7-a0ab-0ca749b54e3f","html_url":"https://github.com/suglasp/pwsh_multithreaded_webserver","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suglasp%2Fpwsh_multithreaded_webserver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suglasp%2Fpwsh_multithreaded_webserver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suglasp%2Fpwsh_multithreaded_webserver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suglasp%2Fpwsh_multithreaded_webserver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/suglasp","download_url":"https://codeload.github.com/suglasp/pwsh_multithreaded_webserver/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243346023,"owners_count":20275939,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["http","https","loadbalancer","multithreaded","powershell","pwsh","scalable","webserver"],"created_at":"2024-11-19T00:50:41.768Z","updated_at":"2025-12-28T01:31:53.552Z","avatar_url":"https://github.com/suglasp.png","language":"PowerShell","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Powershell \"Multithreaded\" Utility Webserver.\n\n( Note : Improved version of [github gist reference](https://gist.github.com/19WAS85/5424431) )\n\n**Why?** \nI needed a webserver to host a tools/utility webpage as a sysadmin.\nThe utility page needed to be flexible and be able to interact with low level components.\nGo lang or Rust would fit to, but takes more time to write and also in Powershell,\nmany of these low level components are present.\nIn a few days, I put this together and make it so, so that more then one user can interact with\nthe webserver at the same time.\n\nThe part _'multithreaded'_ in the github name, is in fact untrue.\nBecause we use Nginx as a loadbalancer in 'front' of the Powershell web instances, it \"looks\" multithreaded.\nBut the true naming is actually horizontal scalability.\n\n**How it works** \n\n- pwsh_webserver_bootstrap.ps1       : is used to start, stop, restart, ... all running instances.\n                                     instances start at port 8080 and ramp up by how much is provided.\n- pwsh_webserver_instance.ps1        : core script, this is a single instance of a webserver.\n- pwsh_webserver_server_raw_stop.ps1 : quick script to stop single instance (script used for development)\n- pwsh_webserver_create_module.ps1   : quick script to create a plugin for the webserver\n\n\n\nThe purpose is the bootstrap script launches a number of web instances (Powershell), and one Nginx instance.\nNginx loadbalances all incomming requests over all web instances.\nNginx should be listening to the ouside world, while the web instances should listen on localhost (in case on a single machine).\nFor performance reasons, one could define routes in the Nginx config for static files (html, js, images, ...).\nIt is possible by changing a parameter to let the web instances listen \"outside\".\n\n\n\n\n**Sub-Folders** \n- ./content : all content goes here (html, htm, css, gif, jpg, png, ico, zip, ...)\n- ./loadbalancer : nginx binary (executable) and all subfolders need to be placed here\n- ./logs : log files of the webserver instances (pwsh_webserver_instance.ps1)\n- ./plugins : plugins go here (basically, they are Powershell modules)\n\n\n**Configuration** \n1) edit config file ./loadbalancer/config/nginx.conf:\n   config the loadbalancer, for example add more web instances, enable ip hasing, enable ssl.\n2) subfolder ./content :\n   place your website content here\n3) Edit file pwsh_webserver_bootstrap.ps1:\n   edit line $global:WebCount, to set the number of instances you want.\n   edit line $global:WebStartPort, to define the start port of the first instance.\n   edit line $global:LoadbalancerUseSSL. If $true (= https), if $false (= http).\n4) Edit file pwsh_webserver_instance.ps1:\n   edit line $global:PublishLocalhost. If $true (= localhost only), if $false (= public).\n\nStarting webserver instances in Powershell (*):\n\u003e .\\pwsh_webserver_bootstrap.ps1 -start\n\nStopping running webserver instances in Powershell (*):\n\u003e .\\pwsh_webserver_bootstrap.ps1 -stop\n\nRestarting webserver instances in Powershell (*):\n\u003e .\\pwsh_webserver_bootstrap.ps1 -reload\n\nSame as '-reload', just to make it easy:\n\u003e .\\pwsh_webserver_bootstrap.ps1 -restart\n\nVerify webserver instances in Powershell:\n\u003e .\\pwsh_webserver_bootstrap.ps1 -verify\n\nDump last 20 lines from nginx error.log in Powershell:\n\u003e .\\pwsh_webserver_bootstrap.ps1 -error\n\nDump last 20 lines from nginx access.log in Powershell:\n\u003e .\\pwsh_webserver_bootstrap.ps1 -access\n\nDump nginx.conf file from Powershell:\n\u003e .\\pwsh_webserver_bootstrap.ps1 -config\n\nClean all log files from Powershell:\n\u003e .\\pwsh_webserver_bootstrap.ps1 -clean\n\nReset webserver stack from Powershell:\n\u003e .\\pwsh_webserver_bootstrap.ps1 -reset\n\n(*) *Running a webserver on ports below 1024 (wel known ports), you must run Powershell (or pwsh) in Elevated mode (Windows) or Root (Linux) to listen on for example port tcp/80 and tcp/443.\nOtherwise, you can just run it normally if it's for testing and running on port tcp/8080 or any of tcp/[1025-65535].*\n\n\n**Provided plugins** \n- Web.Cookies : plugin to handle session cookies\n- Web.PostbackSomeApp : basic plugin sample for form postback processing (someapp example)\n- Web.Redirect : plugin to redirect server side to other page\n- Web.Logon : basic plugin sample to emulate a logon page (also uses the pwsh interpreter tags)\n\n\n**pwsh inline html interpreter** \nThere is a build-in small interpreter, so you can insert pwsh tags in your html code for processing.\nWorks a bit like in php style interpreter code.\n\n\n**Examples included** \n- http://localhost:\u003cinstance_port\u003e/kill   :  route to shutdown the webserver\n- http://localhost:\u003cinstance_port\u003e/ping   :  route to ping the webserver (used with .\\pwsh_webserver_bootstrap.ps1 -verify)\n- http://localhost/cookie :  simple example with cookies\n- http://localhost/       :  example index page, no markup\n- http://localhost/someapp/someapp.html : example app to test image and css loading\n- http://localhost/logon/logon.html : example app to test inline powershell processing and simulate a logon page\n\nPieter De Ridder (Suglasp)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsuglasp%2Fpwsh_multithreaded_webserver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsuglasp%2Fpwsh_multithreaded_webserver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsuglasp%2Fpwsh_multithreaded_webserver/lists"}