Server dynamically configures web application that requires a static configuration without needs to rebuild it. This server is a simple wrapper for nginx or an any web server.
Compatible with: Vue, React, Angular, etc.
- Features
- Usage
- How it works
- Compression
- Environment variables
- Default files in the root directory
- Tests
- License
- Special created for modern web app's.
- Secure headers by default.
- If backend app will be hacked, the hacker may write a letter to us, because email address injected to head section of index (console message) :)
- Corporate config standard supported by default and injected too.
- Brotli-compression (Gzip used as fallback for outdated browsers). Enabled by default. More.
- Deny all
robots.txt
by default. - Hot reload
FROM spacetabio/static-server-php:4.1.0
ARG VCS_SHA1
ARG STAGE
# dist & frontend yaml configuration
COPY dist/ /app
COPY ./configuration /app/configuration
Full example can be founded here.
CLI usage implies 2 commands for usage:
- Start server:
server run
- Reload
After editing files or configuration you can reload the server without restart master process.
server reload
- Dump loaded configuration:
server dump
Comments about server configuration can be found here.
If you would like to optimize web-site for search-indexing bots, server supports integration with this prerender in the box:
https://github.com/spacetab-io/prerender-go
By default, will be added following headers to response:
Pragma: public
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN
X-Content-Type: nosniff
X-Content-Type-Options: nosniff
X-Ua-Compatible: IE=edge
Referrer-Policy: no-referrer
As new feature since 1.1.4
version you able to use Link
header
for server configuration.
- How it use for
<link rel=preload>
requirements (lighthouse), – https://w3c.github.io/preload/#example-3 , https://w3c.github.io/preload/#example-6 - Specification https://tools.ietf.org/html/rfc5988#section-5
Example:
dev:
server:
headers:
link:
- value: </app/style.css>; rel=preload; as=style; nopush
- value:
- <https://example.com/app/script.js>
- rel=preload
- as=script
Server reads files from dist
, then modifying index.html
on the fly
and append a configuration before first <script>
tag will be founded.
Also, available insert config before first tag to <head>
section (but it blocks page painting).
Injected config file (__config.js
) has following content:
window.__stage = 'local';
window.__config = JSON.parse('{}' /* frontend config from yaml here */);
window.__vcs = '%s';
Also, will be injected <link>
tag with rel=preload
. More.
Then, starts the nginx server.
By default, server use Brotli-compression algorithm developed by Google Inc.
If a more effective
(up to 21%) lossless compression algorithm than gzip and deflate.
For the present, his support all modern browsers:
https://caniuse.com/#search=Brotli
Server read the following environment variables:
CONFIG_PATH – server and frontend configuration.
STAGE – server and frontend mode to start: prod/dev/local
VCS_SHA1 – build commit sha1 for debug
By default, root directory is /app
. It special for container-based usage.
Root directory contains following files from scratch:
.
├── favicon.ico
├── index.html
└── robots.txt
favicon.ico
– is a transparent.ico
file (for prevent error logs).index.html
– simple index file with hello message.robots.txt
– the file which blocks all robots by default./.well-known/security.txt
– https://securitytxt.org/
Each file can be replaced.
Install packages for development using composer and just run following command:
vendor/bin/phpunit
The MIT License
Copyright © 2021 spacetab.io, Inc. https://spacetab.io
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.