https://github.com/thma/srv
srv is a tiny web server for local deployments
https://github.com/thma/srv
Last synced: over 1 year ago
JSON representation
srv is a tiny web server for local deployments
- Host: GitHub
- URL: https://github.com/thma/srv
- Owner: thma
- License: apache-2.0
- Created: 2022-06-20T20:04:49.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-12-27T11:15:15.000Z (over 3 years ago)
- Last Synced: 2024-10-29T22:40:29.562Z (over 1 year ago)
- Language: Haskell
- Size: 27.3 KB
- Stars: 9
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# srv
`srv` is a tiny web server for local deployments.
I found it useful for development and testing of static websites and blogs
## Installation
```bash
$ cabal install srv
```
## build from source
```bash
$ git clone https://github.com/thma/srv.git
$ cd srv
$ stack install
-- or if you don't have stack installed
$ cabal install
```
## Usage
```bash
$ cd /path/to/your/documentRoot
$ srv
starting up srv...
srv.yaml not found, generating file with default config
Starting HTTP server on port 8080
Starting HTTPS server on port 8443
```
During the initial run, `srv` will create a config file `srv.yaml`
in the current directory.
You can edit this file to change the port, the directory to serve,
and also select whether to handle HTTP or HTTPS or both.
If HTTPS is selected, you can also provide a certificate and key file.
If you don't provide both files, srv will use a predefined
self-signed certificate which is meant for local demo use only.
(using this demo certificate will result in a warning in your browser
and some browsers will even refuse to connect.)
By default, `srv` will serve the current directory. You can change this by
editing the entry `documentRoot` in the `srv.yaml` file.
By default `srv` will also open a browser window pointing to the directory configured in `documentRoot`. This behaviour can be changed by setting the entry `autoOpenBrowser` to `false`.
## Configuration
Here is a sample configuration file:
```yaml
autoOpenBrowser: true
documentRoot: .
handlers:
- - HTTP
- 8080
- - HTTPS
- 8443
pathToCert: /path/to/certificate.pem
pathToKey: /path/to/key.pem
```
## How to generate your own certificate
```bash
openssl genrsa -out key.pem 2048
openssl req -new -key key.pem -out certificate.csr
openssl x509 -req -in certificate.csr -signkey key.pem -out certificate.pem
```