PHP 8 Server for Nex Protocol
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
2.9 KiB

7 months ago
# next
7 months ago
7 months ago
PHP 8 server for different protocols
7 months ago
Based on [Ratchet](https://github.com/ratchetphp/Ratchet) asynchronous socket library
## Features
7 months ago
* Async socket
* Multi-host
7 months ago
* Multi-protocol:
* [x] [NEX](https://nightfall.city/nex/info/specification.txt)
* [ ] [Gemini](https://geminiprotocol.net)
7 months ago
* Connection event log
* Optional:
7 months ago
* file navigation on directory request
* custom index name
* custom failure template
7 months ago
* Simple and flexible server configuration by CLI arguments
7 months ago
## Install
* `git clone https://github.com/YGGverse/next.git`
* `cd next` - navigate into the project directory
7 months ago
* `composer update` - grab latest dependencies
7 months ago
## Launch
7 months ago
### Start
7 months ago
7 months ago
Create as many servers as wanted by providing different `type`, `host`, `port` and other arguments!
7 months ago
7 months ago
* for security reasons, `next` server prevents any access to the hidden files (started with dot)
* also, clients can't access any data out the `root` path, that defined on server startup
7 months ago
7 months ago
Startup example:
7 months ago
``` bash
php src/server.php type=nex host=127.0.0.1 port=1900 root=/target/dir
7 months ago
```
7 months ago
* `host` and `port` - optional arguments, read [Arguments documentation](#arguments) for details!
7 months ago
#### Arguments
7 months ago
Default argument values depending of server protocol selected.
Some arguments also defined in [default.json](https://github.com/YGGverse/next/blob/main/default.json) file. Do not change it without understanding!
7 months ago
##### Required
7 months ago
* `type` - server protocol, also auto-defines default `port`, supported options:
* `nex` - [NEX Protocol](https://nightfall.city/nex/info/specification.txt)
7 months ago
* `root` - **absolute path** to the public directory, where browser navigation starting from
7 months ago
##### Optional
7 months ago
7 months ago
* `host` - default is `127.0.0.1` e.g. `localhost` connections only
* `port` - default value depends of server `type` selected, for example `1900` for `nex` or `1965` for `gemini`
* `file` - index **file name** that server try to open on directory path requested, disabled by default
7 months ago
* `list` - show content listing in the requested directory (when index `file` not found), enabled by default
7 months ago
* `time` - show file modification time as the alt text in directory listing (useful for gemfeed), disabled by default
7 months ago
* `fail` - **absolute path** to the failure template (e.g. `/path/to/error.gmi`), disabled by default
7 months ago
* `dump` - `enable` or `disable` server debug feature, enabled by default
### Autostart
#### systemd
Following example mean you have `next` server installed into home directory of `next` user (`useradd -m next`)
``` next.service
# /etc/systemd/system/next.service
[Unit]
After=network.target
[Service]
Type=simple
User=next
Group=next
ExecStart=/usr/bin/php /home/next/next/src/server.php type=nex root=/home/next/public
StandardOutput=file:/home/next/debug.log
StandardError=file:/home/next/error.log
Restart=on-failure
[Install]
WantedBy=multi-user.target
```
* `systemctl daemon-reload` - reload systemd configuration
* `systemctl enable next` - enable service on system startup
* `systemctl start next` - start server