How to install freeradiantbunny.
version written with Rust programming language
Part 25 Using nginx as an Intermediary Server that Forwards Client Requests to the freeradiantbunny application
The first step is to install the Rust programming language and all the packages for developing with the Rust programming language. A good place to start is the document on the mudia.link site called: How To Install Rust Command Beakdown.
This is what the command looks like, but get the current command from the Rust Install website https://www.rust-lang.org/tools/install curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Clone the freeradiantbunny code from the GitHub repository.
$git clone git@github.com:lplinden/freeradiantbunny.git
Examine the files of the freeradiantbunny.
$cd to the directory of the freeradiantbunny project $cargo buildThere may be a "cc not found" message. So install cc.
$sudo apt-get install gcc
Now, the compiler should be ready to go. Try the following command again. (If all goes well the compiler will compile the Rust code into an executable file.
$cargo build --release OUTPUT:Compiling autocfg v1.1.0 Compiling libc v0.2.147 Compiling cfg-if v1.0.0 Compiling version_check v0.9.4 Compiling typenum v1.16.0 Compiling generic-array v0.14.7 Compiling memchr v2.5.0 Compiling proc-macro2 v1.0.66 Compiling futures-core v0.3.28 Compiling unicode-ident v1.0.11 Compiling pin-project-lite v0.2.10 Compiling quote v1.0.32 Compiling syn v2.0.27 Compiling crossbeam-utils v0.8.16 Compiling slab v0.4.8 Compiling value-bag v1.4.1 Compiling log v0.4.19 Compiling block-buffer v0.10.4 Compiling crypto-common v0.1.6 Compiling unicase v2.6.0 Compiling subtle v2.5.0 Compiling event-listener v2.5.3 Compiling digest v0.10.7 Compiling concurrent-queue v2.2.0 Compiling getrandom v0.2.10 Compiling socket2 v0.4.9 Compiling lock_api v0.4.10 Compiling tinyvec_macros v0.1.1 Compiling futures-io v0.3.28 Compiling bytes v1.4.0 Compiling parking_lot_core v0.9.8 Compiling once_cell v1.18.0 Compiling fastrand v1.9.0 Compiling parking v2.1.0 Compiling io-lifetimes v1.0.11 Compiling waker-fn v1.1.0 Compiling futures-lite v1.13.0 Compiling tinyvec v1.6.0 Compiling rand_core v0.6.4 Compiling async-lock v2.7.0 Compiling polling v2.8.0 Compiling scopeguard v1.2.0 Compiling ppv-lite86 v0.2.17 Compiling smallvec v1.11.0 Compiling serde v1.0.176 Compiling rustix v0.37.23 Compiling cpufeatures v0.2.9 Compiling rand_chacha v0.3.1 Compiling mime_guess v2.0.4 Compiling unicode-normalization v0.1.22 Compiling num-traits v0.2.16 Compiling tokio v1.29.1 Compiling async-io v1.13.0 Compiling serde_derive v1.0.176 Compiling bitflags v1.3.2 Compiling futures-sink v0.3.28 Compiling async-task v4.4.0 Compiling futures-task v0.3.28 Compiling libm v0.2.7 Compiling unicode-bidi v0.3.13 Compiling linux-raw-sys v0.3.8 Compiling stringprep v0.1.3 Compiling parking_lot v0.12.1 Compiling rand v0.8.5 Compiling sha2 v0.10.7 Compiling tracing-core v0.1.31 Compiling async-channel v1.9.0 Compiling hmac v0.12.1 Compiling md-5 v0.10.5 Compiling tokio-macros v2.1.0 Compiling signal-hook-registry v1.4.1 Compiling num_cpus v1.16.0 Compiling mio v0.8.8 Compiling futures-channel v0.3.28 Compiling byteorder v1.4.3 Compiling async-trait v0.1.72 Compiling fallible-iterator v0.2.0 Compiling siphasher v0.3.10 Compiling mime v0.3.17 Compiling pin-utils v0.1.0 Compiling futures-util v0.3.28 Compiling minimal-lexical v0.2.1 Compiling base64 v0.21.2 Compiling atomic-waker v1.1.1 Compiling blocking v1.3.1 Compiling postgres-protocol v0.6.5 Compiling nom v7.1.3 Compiling phf_shared v0.11.2 Compiling tracing v0.1.37 Compiling basic-toml v0.1.4 Compiling async-executor v1.5.1 Compiling futures-macro v0.3.28 Compiling aho-corasick v1.0.2 Compiling percent-encoding v2.3.0 Compiling regex-syntax v0.7.4 Compiling regex-automata v0.3.3 Compiling async-global-executor v2.3.1 Compiling humansize v2.1.3 Compiling askama_derive v0.12.1 Compiling tokio-util v0.7.8 Compiling phf v0.11.2 Compiling postgres-types v0.2.5 Compiling kv-log-macro v1.0.7 Compiling digest v0.9.0 Compiling block-buffer v0.9.0 Compiling socket2 v0.5.3 Compiling time v0.1.45 Compiling askama_escape v0.10.3 Compiling itoa v1.0.9 Compiling opaque-debug v0.3.0 Compiling fnv v1.0.7 Compiling iana-time-zone v0.1.57 Compiling chrono v0.4.26 Compiling http v0.2.9 Compiling sha2 v0.9.9 Compiling askama v0.12.0 Compiling tokio-postgres v0.7.8 Compiling async-std v1.12.0 Compiling regex v1.9.1 Compiling vec_map v0.8.2 Compiling freeradiantbunny v0.0.5 (/home/username/master_dev/master_freeradiantbunny_rust/frbrust/freeradiantbunny) Finished release [optimized] target(s) in 4m 22sOk, you should now have an executable file. These show it. Run the command below, noting where the compile generated the executable file.
$ls target OUTPUT:?Application: Rust programming language
The version of freeradiantbunny is written using the Rust programming language.
At this point the documents the server has been set up. We use nginx as an intermediary server that forwards the clients request to freeradiantbunny.
Here our development path diverge. There are two paths each with its own programming language implementation, one for Javascript and one for Rust.
The main (current) path is the version of freeradiantbunny that is written using the Rust programming language.
The other (older version not supported) path is the version of freeradiantbunny that was written suing javascript and the node.js module. These docs are further down the page, so jump to docs on javascript version.
When you set up the reverse proxy configuration in Nginx you will configure the name of the software version you plan to use for your freeradiantbunny.
$emacs /etc/nginx/sites-available/[domain-name]Scroll down (or search) to the "server" keyword and within the curly brackets then scroll down to after the server_name, and add the following 4 lines (1 comment and 3 proxy_set_header commands:
Here is what the code looks like: # add lines for proxy proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
After those lines, scroll down to the location keyword and 4 lines (1 comments and 3 code lines including a proxy_pass line of code. The whole section is shown below. Note, that the location is specified as the root directory with the forward-slash.
Your port number may be different. Check Part 26 Mange the Port
# proxy location ~ ^/(classes|subsystems|zachmans|applications|domains|webpages|plants|plant_lists|plant_families|maxonomies|modules) { proxy_pass http://localhost:[port-number]; }Ask how the application knows the port-number. Need to configure the freeradiantbunny applications.
The freeradiantbunny has a main.rs file of code and that code has a line that reads:
let listener = TcpListener::bind(IP_ADDRESS_AND_PORT)?;
In the code line above, note the IP_ADDRESS_AND_PORT constant variable. This contains the port number. The constant is defined in the freeradiantbunny configuration directory with is names as dot file and should be locate in the user's home directory.
$ls ./.freeradiantbunny
Use a text editor to inspect this file.
Edit [port-number] instructions: {todo).Reload the configuration of the nginx server.
$sudo systemctl reload nginx $cd ~/freeradiantbunny.nodeNote that you need to specify the port in the site_configuration.rs file.
./src/freeradiantbunny/site_configuration/site_configuration.rs:pub const IP_ADDRESS_AND_PORT: &str = "[localhost-ip-address]:[site-port]";In the site_configuration.rs file you should also specify the [localhost-ip-address].
You then have to specify the domain.
pub const KNOWN_HOSTS: [(&str, &str); 6] = [ ("localhost:[port-number]", "/public_[domain-tli]"), ("[domain-name]", "/public_[domain-tli]"), ];Also need to consider if the restarts the app after a server reboot.
How to shutdown the freeradiantbunny app.
$ To test, open a browser and visit a URL that will engage the freeradiantbunny.org npm. https://[domain-name]/classes There may be a 404 File Not Found response, because the class_name is not known or because the database is not yet installed.Also, it may be helpful to edit the .bash_aliases file and add command shortcuts. See the two shortcuts below, one for the build and one for the run.
alias cb='cargo build 2>&1 | less' alias cr='cargo run > ~/.freeradiantbunny/proxy_output.txt' OUTPUT:Finished release [optimized] target(s) in 0.09s Running `target/release/freeradiantbunny`Show the process running on the system.
$ps aux | grep freeradiantbunny OUTPUT:username 73276 0.0 0.5 209276 5112 ? S 17:42 0:00 target/release/freeradiantbunny username 73438 0.0 0.2 7056 2176 pts/0 S+ 17:48 0:00 grep --color=auto freeradiantbunnyAlso, if the program crashes, the following 2 commands will enable you to determine the number of the process, and the killing of that process number.
$ps aux | grep freeradiantbunnyBelow is what a screenprint of a typical install.
When testing, also use the curl command-line browser.
File: .bash_aliases
Part 26 Manage the Port
Node: need to add a rule using commandline, such that the firewall knows of an open port [port-number].
$sudo ufw from 127.0.0.1 to any port [port-number] Check that he command took effect. $sudo ufw statusPart 27 Install the version written with Rust code
This section needs to be written once the code is uploaded. Go to github. Use git to download code.
Configure the code.
Compile the code.
Above is the Rust version of freeradiantbunny.
Below is the Javascript version of freeradiantbunny (not supported).
version written with javascript and using node.js
These are the documents on how to install the version of the freeradiantbunny application that is written in the javascript programming language. This version is not supported, but made available as a reference.
Part 25B. Install Node.js.
Note: Use a browser and surf to nodejs.org. At this site, find the downloads. Then find the link to a webpage about installing from a "package manager". On the package manager page, scroll until you find the Ubuntu / Debian section listing some command-line commands.
Here is an example of the url where the I found this info:
nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions
Note: It appears that you also get to decide on which version of node to use. n this example, I am using version "Ubuntu 18.04 LTS (Bionic Beaver)".
Also, select the version of node.js (v13.0).
So, from the nodejs.org webpage copy the following lines and paste then in a terminal and execute them. They download the node code so that it can be added to the system as a apt-get package.
This is where it led me:
github.com/nodesource/distributions/blob/master/README.md
Here are the commands from the above that were used to install Node.js Current (v17.x):
Tell the system about the nodejs code from repository.
$curl -fsSL https://deb.nodesource.com/setup_current.x | sudo -E bash -
Take a breathe, stretch, and then continue with the following.
Now, install nodejs. $sudo apt-get install -y nodejs Check that you have node.js on your droplet. Test this by using the following command: $node -v $npm -v One one machine, I had debian and I needed to run the following to get the above to work. $sudo apt-get install nodejs-legacy/.
Next, we will install a manager to manage our node.js application.
Application: nodejs
This is the wonderful node.js application.
Part 26B. Install pm2 to run the server.js as a process.
I know, I know. More typing.
$sudo npm install pm2 -g $pm2 update
Application: pm2
Manage the nodejs application which be a file named server.js. This will run webserver as a service.
Part 27B. Configure pm2 to start on boot.
Enable server start on system reboot. The way this works, is that you run a command that will generate a shell script line of code that can then be run to install the startup command into the system.
$pm2 startup
Note: follow the instructions, you will have to copy the output and paste it on the command line and then run it.
Here is what the generated line of shell code looked like: sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u [user-name] --hp /home/[user-name] Then the next command tells the startup what servers to run upon startup. $pm2 save
Part 28B. Install freeradiantbunny.node.
Install the node.js webserver. First we install the container known as freeradiantbunny.node.
Install from github. $git clone https://github.com/lplinden/freeradiantbunny.node.git The git app returns: Cloning into 'freeradiantbunny.node'... remote: Enumerating objects: 14, done. remote: Counting objects: 100% (14/14), done. remote: Compressing objects: 100% (10/10), done. remote: Total 14 (delta 3), reused 7 (delta 3), pack-reused 0 Unpacking objects: 100% (14/14), 43.46 KiB | 2.72 MiB/s, done. Inspect the file system and notice that there is a new directory. $ls freeradiantbunny.node $cd freeradiantbunny.node $git status Shows that the code is on the master branch. Update the node modules that are dependencies. $npm update $npm audit fix --force Notice that the code of the freeradiantbunny npm has been installed. $ls node_modules/freeradiantbunny/
Nothing to study for this part. You have the night off.
Part 29B. Add configuration file for freeradiantbunny npm.
Note, the options are to take a file from freeradiantbunny code, copy it over, and modify it.
The freeradiantbunny npm needs a configuration file. See:
ls ~/.freeradiantbunny/config.js $mkdir ~/.freeradiantbunny install ~/.freeradiantbunny/config.js edit [ip-address] in the file
That was Part 17, during which we configured the application.
Part 30B. Set up rotating logs for pm2.
pm2 install pm2-logrotate
This is the end of this install doc.
back to the start How to install freeradiantbunny.