From f92355592a49ef844b9beb376790547020be4e32 Mon Sep 17 00:00:00 2001 From: Chrystian Huot Date: Wed, 29 Jun 2022 11:33:27 -0400 Subject: [PATCH] Add NGINX and Apache HTTP reverse proxy examples --- docs/examples/apache/.htaccess | 11 ++++++ docs/examples/apache/README.md | 3 ++ docs/examples/nginx/README.md | 3 ++ docs/examples/nginx/nginx.conf | 61 ++++++++++++++++++++++++++++++++++ 4 files changed, 78 insertions(+) create mode 100644 docs/examples/apache/.htaccess create mode 100644 docs/examples/apache/README.md create mode 100644 docs/examples/nginx/README.md create mode 100644 docs/examples/nginx/nginx.conf diff --git a/docs/examples/apache/.htaccess b/docs/examples/apache/.htaccess new file mode 100644 index 0000000..0326993 --- /dev/null +++ b/docs/examples/apache/.htaccess @@ -0,0 +1,11 @@ +# Create a rdio-scanner subfolder under the DOCUMENT_ROOT and put this file in it. +# Don't forget to change 127.0.0.1:3000 to the internal IP of your Rdio Scanner instance. + +DirectoryIndex index.html + +RewriteEngine on + +RewriteCond %{HTTP:CONNECTION} ^upgrade$ [NC,OR] +RewriteCond %{HTTP:UPGRADE} ^websocket$ [NC] +RewriteRule ^/?(.*)$ ws://127.0.0.1:3000/$1 [P,L] +RewriteRule ^/?(.*)$ http://127.0.0.1:3000/$1 [P,L] \ No newline at end of file diff --git a/docs/examples/apache/README.md b/docs/examples/apache/README.md new file mode 100644 index 0000000..3487baa --- /dev/null +++ b/docs/examples/apache/README.md @@ -0,0 +1,3 @@ +# Apache HTTP server + +Simple Apache HTTP `.htaccess` to reverse proxy to an internal Rdio Scanner instance. \ No newline at end of file diff --git a/docs/examples/nginx/README.md b/docs/examples/nginx/README.md new file mode 100644 index 0000000..158d9be --- /dev/null +++ b/docs/examples/nginx/README.md @@ -0,0 +1,3 @@ +# NGINX + +Simple NGINX configuration that reverse proxy /rdio-scanner path to an internal instance. \ No newline at end of file diff --git a/docs/examples/nginx/nginx.conf b/docs/examples/nginx/nginx.conf new file mode 100644 index 0000000..d4b617f --- /dev/null +++ b/docs/examples/nginx/nginx.conf @@ -0,0 +1,61 @@ +worker_processes auto; + +error_log /var/log/nginx/error.log notice; +pid /var/run/nginx.pid; + +events { + worker_connections 1024; +} + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + sendfile on; + keepalive_timeout 65; + + map $http_upgrade $connection_upgrade { + default upgrade; + '' close; + } + + upstream rdio-scanner { + server 127.0.0.1:3000; + } + + server { + listen 80 default_server; + listen [::]:80 default_server; + + # listen 443 ssl default_server; + # listen [::]:443 ssl default_server; + # + # ssl_certificate /etc/ssl/certs/ssl-cert-snakeoil.pem; + # ssl_certificate_key /etc/ssl/private/ssl-cert-snakeoil.key; + + root /var/www/html; + + index index.html index.htm; + + server_name _; + + location / { + try_files $uri $uri/ =404; + } + + location /rdio-scanner/ { + rewrite ^/rdio-scanner/(.*)$ /$1 break; + proxy_pass http://rdio-scanner; + } + + proxy_http_version 1.1; + proxy_set_header Connection $connection_upgrade; + proxy_set_header Host $host; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } +}