Build websites in Swift.
The Swiftfire webserver can be extended with functions and services written in Swift. Making it possible to create entire websites written in nothing else but HTML, CSS and Swift. No other languages, frameworks or external services necessary, with a minor exception for openSSL.
Since the website and server-software are merged into one, you will need access to your own server-hardware. This can be any old computer as long as it is able to run MacOS 10.11 (El Capitan).
Linux compatibility is envisaged, but not yet actively supported.
Visit the Swiftfire homepage at http://swiftfire.nl.
How it works
This is a very high level overview of how Swiftfire can use Swift code to create websites.
Every domain that is hosted under Swiftfire implements a stack of services. By default that stack implements a static website.
For each (valid and accepted) request that arrives at the server, Swiftfire finds the stack of services to execute and does so one by one.
You can add your own services to modify or extend de default behaviour.
However it is much more likely that you will want to create your own functions.
Functions can be used to inject HTML code into otherwise "static" web pages. Giving them dynamic qualities.
One of the services in the stack of services retrieves the requested page from disk and verifies if it must be parsed. If it must be parsed it scans the file for 'functions'. Any function that is found is executed, and the result of the execution is injected into the page at the exact spot of the function. The function itself is removed.
<p>This page has been accessed .nofPageHits() times</p>
is translated to:
<p>This page has been accessed 59440 times</p>
or any other number of course.
The best part is, you can define and write the functions yourself.
It is up to you to determine how much you want to do in Swift. For example, you could decide to have the entire landing page to be created by a function. To do that let index.sf.html exists only of:
.buildLandingPage(). And of course you have to implement the function that is registered under the name
Swiftfire is a faceless webserver application. However it comes with a website that can be used for administration purposes. On initial start of the server, any request on the port on which the server listens will result in a landing page that asks to create an admin account and the directory in which the administration site is installed.
Once set up, any access to the port that has as its URL: '/serveradmin' will end up on the login page of the server administrator website. Note that the login is only as secure as the protocol. Use HTTP only when accessing from within a private LAN.
This is an early public beta release.
However: It does work! :-)
- Allows code injection (HTML and CSS) from functions written in Swift
- Allows website services to be implemented in Swift
- Out of the box support for static websites
- Handles multiple domains
- Sessions are supported
- Accounts are supported
- Client forwarding (to other hosts or a different port on the same host)
- Integrated usage statistics (page visits)
- Blacklisting (refusal of service) on IP basis for Server and per domain
- Supports HTTP1.0 and HTTP1.1
- Supports HTTPS
- Web based interface for Swiftfire Administrator
- Custom pages for errors (for example the infamous 404 page not found)
- Logging of received headers possible
- Logging of missing pages (404)
- Console application available
Note: Planned releases are for information only and almost always change.
2.0.0 (Thought about)
- Add URL redirection list
- A few (1-6) months after v0.12.0 (Confidence building period)
- Small feature improvements (if necessary)
- Code improvements
- Restored compilability (Still, do not use this release)
- Temporary release for code consolidation purposes while migrating to Swift 4 and SPM 4.
- Do not use this release, it does not compile!
- Bugfix: fixed hanger on URLs containing an 'and' (&) sign
- Bugfix: added header logging back in
- Upgraded SwifterJSON to VJson
- Better HTML support for code generation (improving the admin interface)
- Added handling of (very) large HTTP request bodies
- Completion of server admin web based interface
- Removal of code related to SwifterConsole (no longer supported)
- Silenced warning during compilation
- Removed dependency on macOS 10.11
- Through an upgrade of SwifterSockets fixed two server bugs (one caused a crash the other ran out of connection objects)
- Added server admin web based interface (still incomplete)
- Added "Account" support
- Added session support
- Code improvements
- Minor bugfixes
- Fixed typo of blacklist in log
- Added debug output to service invokation
- Fixed memory leak from SwifterJSON
- Bugfix: inactivity on m&c interface no longer causes a crash.
- Bugfixes in SwifterSockets and SwiftfireCore
- Changes in SwiftfireConsole for xcode 8.3
- Removed warnings due to Xcode 8.3
- Added support for functions (HTML & CSS code injections)
- Added HTTPS support
- General update of headers
- Use SSL for the interface to SwiftfireConsole
- Infrastructure update (no code changes).
- Switched to SwiftPM distribution
- Updated for new approach in SwifterSockets
- Added IP Address block list (blacklists)
- Added custom error pages (for example the 404 error) support
- Upgrade to Xcode 8 beta 6 (Swift 3)
- Major improvements of the GUI console
- Updated for Xcode 8 beta 3 (Swift 3)
- Added usage charts that track the number of page visits over time
- Added enabling/disabling of visit counting for specific resources
- Merged SwiftfireConsole into this project as an extra target
- Added usage statistics for client & domain usage.
- Updated for VJson 0.9.8
- Added domain statistics
- Fixed a bug in SwifterSockets that would not log correct IPv6 addresses.
- Fixed a number of bugs that messed up logging of access and 404
- Renamed FileLog to Logfile
- Replaced header logging code with usage of Logfile
- Quick fix for bug that would prevent creation of AccessLog and Four04Log.
- Cleaned up parameter definition setting and usage
- Added option to log all HTTP request headers
- Added option to log all access to a domain
- Added option to log all URLs that result in a 404 reply
- Few minor bug fixes (minor = will probably never occur and does not impact functionaly)
- Header update to include new website: swiftfire.nl
- Removed Startup, folded into Parameters
- Merged MAX_NOF_PENDING_CLIENT_MESSAGES with MAX_CLIENT_MESSAGE_SIZE into CLIENT_MESSAGE_BUFFER_SIZE
- Save & Restore no longer preserve telemetry values
- Added transmission of "ClosingMacConnection" info upon timeout for the M&C connection
- Added ResetDomainTelemetry command
- Fixed bug that prevented domain creation
- Added MIME type support based on the file extension
- Switched to VJSON pipe operators
- Simplified the SwifterConsole M&C interface
- Added domain telemetry
- Minor changes to accomodate changes in other packages
- Minor changes to accomodate changes in SwifterSockets/SwifterLog/SwifterJSON
- Added 'descriptionWithSeparator' to Extensions.swift
- Added release tags
- Initial public release
Help us keep the lights on
0.11.1 - Apr 10, 2018
The app compiles and runs again, but has not been tested. Also note that the feature set is changing. The last stable release is 0.10.11
0.11.0 - Apr 9, 2018
This release is for internal purposes only, do not use this code base, use release 0.10.11 or wait until the next release.
0.10.11 - Jul 3, 2017
Fixed a bug on processing a URL with a '&' in it (caused a 'hanger') Fixed missing header logging
Upgraded (rename) SwifterJSON to VJson
0.10.10 - Jun 8, 2017
In this release the serveradmin interface was improved on the code generation side of things. A.o. an HTML subproject was introduced to do the HTML code generation.
As of this release, Swiftfire now supports very large HTTP request bodies. Previously this was limited to about 32KB, now the size is nearly unlimited. A new service was introduced to enforce completeness of HTTP requests for the traditional 'static websites'. If websites want to make use of very large HTTP bodies, they will need to implement a service specifically for that purpose.
0.10.9 - May 25, 2017
As of this release, the SwiftfireCore and SwifterfireConsole have been discontinued. Swiftfire now has a build-in administration site that can be reached under "(any-domain)/serveradmin". The id/password must be set during the initial deployment of the server. In addition a new (sub)project 'Html' has been added to create HTML code.
Inspired by the mailing list "swift-sever-dev" (See https://swift.org/community/#mailing-lists) the next release (0.10.10) will offer support for (very) large HTTP request bodies.