Lastly, tested on Erlang/OTP 28, and it is the recommended version now.
First, you need to copy configurations:
cp -r configs/ /etc/MeowMeow/ # You may need sudotAlternatively, you may edit src/config.hrl:
%%...
%% Replace /etc/MeowMeow/ with your desired path to configs
-define(accessfile, "/etc/MeowMeow/routes.conf").
-define(configfile, "/etc/MeowMeow/meow.conf").
%%...The best way to debug the program is just to run it with rebar3:
rebar3 shellCompile using rebar3:
$ rebar3 as prod release
Then you need to create configs in /etc/MeowMeow/. After this you can run server:
$ ./_build/prod/rel/MeowMeow/bin/MeowMeow <desired mode of running>
If you need help on modes of running just execute script with no arguments to get help.
IMPORTANT NOTICE: In current version syntax errors in config are NOT checked, so misconfiguration may lead to fatal errors.
Server configuration is stored in /etc/MeowMeow/meow.conf. The syntax is as follows:
Directive1 Args
Directive2 Args
Current version support following directives:
LogLevel <<LEVEL>>set logging level from 0 to 4(0 -- log nothing,4 -- log everything)KeepAlive <<MS>>default connection keep-alive time in millisecondsListenPort <<PORT>>port where to listen for connectionsListenHost <<HOSTNAME/IP>>hostname to listen onDocDir <<DIRECTORY>>directory with files to serve
To configure routes you need to edit /etc/MeowMeow/routes.conf. The syntax is as follows:
Route <wildcard pattern>
Directive1 Args
Directive2 Args
Host <wildcard pattern>
Directive3 Args
End
End
Route defines pattern of request paths for which directives would be applied. Additionally directives can be applied by Host header(as in an example above). Directives are applied in order as they added in the config file.
The directives currently supported by server:
Abort <<CODE>>- stop processing request and send HTTP/1.1 status code<<CODE>>to clientNo-Content- sendsHTTP/1.1 204 No Contentto clientDisallow- sendsHTTP/1.1 403 Forbiddento clientSet-Header <<HEADER>> <<VALUE>>- sets response header<<HEADER>>to<<VALUE>>Set-Code <<CODE>>sets status code for a response.
Warning
There are, so called, "terminal" directives.
They stop further processing of the request and send response to client.
In this section those are Abort, No-Content and Disallow.
Modules must specifically tell which directives are terminal.
Sometimes, you cannot apply the terminal directive straight ahead. For example, you may want to set a header, then process mimes, and if the host is localhost, do completely something else, but keeping the same header. In such a case you may split rules and apply them twice as in example below:
# First set header which will be applied to all routes
Route *
Set-Header X-Powered-By "Pusheen The Cat"
End
# Now apply mimes
Include "/etc/MeowMeow/mimes.conf"
# Now apply localhost rule, so if Host header is localhost,
# we will send localcat.html
Host localhost
Set-Header Content-Type "text/html"
Send-File "/var/www/html/localcat.html"
End
# Finally, apply default rule: send respective file from /var/www/html
Route *
DocDir /var/www/html
End
# It is impossible to reach this route,
# since DocDir already would apply to it and
# send off request to the client.
Route /never_reachable
Abort 418
End
You can see an example of routing rules configuration here or in tests
From scratch MeowMeow would not serve anything.
Default configuration, though loads module static which serves static files from /var/www/ directory by default.
If you need any additional modules or do not want to static you should edit /etc/MeowMeow/modules.conf file:
LoadModules <module1>,<module2>...
Static module is intended to serve static files.
Automatically serves any file from a given directory.
For example, if you would like to server from traditional /var/www/html, you may write:
DocDir /var/www/html
Important
This is a terminal rule. It will send off the response and stop further processing.
Sends file from a given path. Accepts single argument, which is a path to file.
Send-File /opt/meow/nya.html
Important
This is a terminal rule. It will send off the response and stop further processing.