Web Features¶
Create Railways Navigator can expose your rail network over the network so external websites, tools and dashboards can read live train data. All of this is provided by the built-in REST API.
The web server is turned off by default. It only starts when you enable it in the config. Since this is a real network service, see the Security note before enabling it.
Enabling the Web Server¶
The web server is configured in the common-config of the server or singleplayer world. Set web.enabled to true and restart your world or server.
Once running, it listens on the configured address and port and serves the content under one of these URLs:
http://<ip>:<port>/crn
http://<ip>:<port>/createrailwaysnavigator
URL Example
If you are using the default settings and you are playing on singleplayer or a local server, the base URL will look like this:
http://localhost:25580/crn
Configuration¶
You can find all options under the web keys of the common-config. Please read the description of the config file for more information.
Security¶
The web server is unauthenticated
Anyone who can reach the port can read all data the API exposes. There is no login or API key yet.
- Leave the web features off unless you actually need it.
- To only allow access from the same machine (for example behind a reverse proxy), set
web.bind_addressto127.0.0.1. Use0.0.0.0to allow any machine on the internet to access your API. - The server speaks plain HTTP only. For HTTPS, put a reverse proxy (nginx, Caddy, ...) in front of it.
web.cors_allowed_originsonly controls which websites a browser lets read the responses. It is not an access restriction for other clients.
Dependencies¶
This project uses the Open Source project Eclipse Jetty to provide its web server and HTTP functionality. Jetty is available under the Eclipse Public License 2.0 and the Apache License 2.0. You can find the official source code and documentation here: https://github.com/jetty/jetty.project