rstudio / plumber

Turn your R code into a web API.
https://www.rplumber.io
Other
1.39k stars 255 forks source link

Improvement of documentation on systemd section #912

Open rrbaptista opened 1 year ago

rrbaptista commented 1 year ago

The systemd part from the official documentation feels a little bit incomplete.

I suggest adding a nginx approach using proxy_pass, after the systemctl enable and start step.

  1. Make sure your Plumber instance is running on 127.0.0.1 on the ExecStart parameter on the service file.
  2. Open the sites-enabled folder on /etc/nginx/ or the correspondent path if you're using a custom nginx installation.
  3. Inside the server block on your desired file (mine is default), create a location block with the name you want.
  4. If your Plumber instance is running on the 6547 port, put the code below inside the newly created block to make your endpoints available on the web.
location /api/ {
proxy_pass http://127.0.0.1:6547;
proxy_http_version 1.1;
}
  1. Restart nginx after the changes.
  2. On this example, your endpoints will be available on https://example.com/api/

I don't recommend using rewrite rules, because the regex parameters can lead to unpredictable behavior when using the endpoints.