The static module of Space Cloud provides an easy way to host your static files. It can also act as an reverse proxy to other upstream servers in your system. However, it's not meant to replace full blown web servers like Nginx or Apache. In fact, for more advanced use cases, Space Cloud would come behind a reverse proxy server like Nginx or Apache. Space Cloud can come in handy in simple use cases like hosting a website alongside your backend (Space Cloud), where something like Nginx or Apache will be an overkill or difficult to start with.
Configuring static module
The configurations for static module goes inside the
static section in
modules. It contains two options:
- enabled: - To enable the static module
- routes: An array of
route consists of the following fields:
- host: Name of the host
- prefix: Prefix of the incoming request
- path: Path of the folder containing static resources (used for static hosting)
- proxy: Address of the upstream server to proxy incoming request (used for reverse proxy)
Serve static resources
Here's an sample config of how to host static resources via Space Cloud:
modules: static: enabled: true routes: - host: console.spaceuptech.com prefix: /home path: /public/console
The above configuration will host the folder the static resources at
/public/console for any requests at console.spaceupetch.com starting with
Here's how Space Cloud can be configured to act as a reverse proxy server to other servers in your system:
modules: static: enabled: true routes: - host: spaceuptech.com prefix: /v1/ proxy: http://localhost:8090/v1/
Serving an SPA like ReactJS or AngularJS is different from serving a static website. Space Cloud can't natively host an SPA as of now. However, you can serve them via something like serve and use Space Cloud as a reverse proxy to them.
Great, you have learned how to host static resources via Space Cloud. You can continue to see how to deploy Space Cloud.