remove index.html pointer from docker nginx confs and host-your-own.md as it is unnecessary for the implemented node only solution

This commit is contained in:
schlagmichdoch 2023-02-10 12:43:16 +01:00
parent 36080f6935
commit 206b42614d
3 changed files with 83 additions and 38 deletions

View file

@ -4,11 +4,6 @@ server {
expires epoch; expires epoch;
location / { location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
location /server {
proxy_connect_timeout 300; proxy_connect_timeout 300;
proxy_pass http://node:3000; proxy_pass http://node:3000;
proxy_set_header Connection "upgrade"; proxy_set_header Connection "upgrade";
@ -31,11 +26,6 @@ server {
expires epoch; expires epoch;
location / { location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
location /server {
proxy_connect_timeout 300; proxy_connect_timeout 300;
proxy_pass http://node:3000; proxy_pass http://node:3000;
proxy_set_header Connection "upgrade"; proxy_set_header Connection "upgrade";

View file

@ -22,11 +22,6 @@ server {
expires epoch; expires epoch;
location / { location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
location /server {
proxy_connect_timeout 300; proxy_connect_timeout 300;
proxy_pass http://node:3000; proxy_pass http://node:3000;
proxy_set_header Connection "upgrade"; proxy_set_header Connection "upgrade";

View file

@ -45,7 +45,7 @@ When serving the node server behind a proxy, the `X-Forwarded-For` header has to
## Deployment with node ## Deployment with node
```bash ```bash
git clone https://github.com/Bellisario/node-snapdrop.git && cd node-snapdrop git clone https://github.com/schlagmichdoch/PairDrop.git && cd PairDrop
``` ```
Install all dependencies with NPM: Install all dependencies with NPM:
@ -94,6 +94,7 @@ npm start:prod
You must use nginx or apache to set the x-forwarded-for header correctly. Otherwise, all clients will be mutually visible. You must use nginx or apache to set the x-forwarded-for header correctly. Otherwise, all clients will be mutually visible.
### Using nginx ### Using nginx
#### Allow http and https requests
``` ```
server { server {
listen 80; listen 80;
@ -101,11 +102,6 @@ server {
expires epoch; expires epoch;
location / { location / {
root /var/www/pairdrop/public;
index index.html index.htm;
}
location /server {
proxy_connect_timeout 300; proxy_connect_timeout 300;
proxy_pass http://node:3000; proxy_pass http://node:3000;
proxy_set_header Connection "upgrade"; proxy_set_header Connection "upgrade";
@ -122,11 +118,34 @@ server {
expires epoch; expires epoch;
location / { location / {
root /var/www/pairdrop/public; proxy_connect_timeout 300;
index index.html; proxy_pass http://node:3000;
proxy_set_header Connection "upgrade";
proxy_set_header Upgrade $http_upgrade;
proxy_set_header X-Forwarded-for $remote_addr;
} }
}
```
#### Automatic http to https redirect:
```
server {
listen 80;
location /server { expires epoch;
location / {
return 301 https://$host:8443$request_uri;
}
}
server {
listen 443 ssl http2;
ssl_certificate /etc/ssl/certs/pairdrop-dev.crt;
ssl_certificate_key /etc/ssl/certs/pairdrop-dev.key;
expires epoch;
location / {
proxy_connect_timeout 300; proxy_connect_timeout 300;
proxy_pass http://node:3000; proxy_pass http://node:3000;
proxy_set_header Connection "upgrade"; proxy_set_header Connection "upgrade";
@ -136,28 +155,36 @@ server {
} }
``` ```
### Using Apache ### Using Apache
#### Allow http and https requests
``` ```
<VirtualHost *:80> <VirtualHost *:80>
DocumentRoot "/var/www/pairdrop/public"
DirectoryIndex index.html
RewriteEngine on RewriteEngine on
RewriteCond %{HTTP:Upgrade} websocket [NC] RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteCond %{HTTP:Connection} upgrade [NC] RewriteCond %{HTTP:Connection} upgrade [NC]
RewriteRule ^/?(.*) "ws://127.0.0.1:3000/$1" [P,L] RewriteRule ^/?(.*) "ws://127.0.0.1:3000/$1" [P,L]
</VirtualHost> </VirtualHost>
<VirtualHost *:443> <VirtualHost *:443>
DocumentRoot "/var/www/pairdrop/public"
DirectoryIndex index.html
RewriteEngine on RewriteEngine on
RewriteCond %{HTTP:Upgrade} websocket [NC] RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteCond %{HTTP:Connection} upgrade [NC] RewriteCond %{HTTP:Connection} upgrade [NC]
RewriteRule ^/?(.*) "wws://127.0.0.1:3000/$1" [P,L] RewriteRule ^/?(.*) "wws://127.0.0.1:3000/$1" [P,L]
</VirtualHost> </VirtualHost>
``` ```
#### Automatic http to https redirect:
```
<VirtualHost *:80>
Redirect permanent / https://127.0.0.1:3000/
</VirtualHost>
<VirtualHost *:443>
RewriteEngine on
RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteCond %{HTTP:Connection} upgrade [NC]
RewriteRule ^/?(.*) "wws://127.0.0.1:3000/$1" [P,L]
</VirtualHost>
```
## Deployment with Docker ## Deployment with Docker
The easiest way to get PairDrop up and running is by using Docker. The easiest way to get PairDrop up and running is by using Docker.
@ -171,7 +198,8 @@ When running PairDrop via Docker, the `X-Forwarded-For` header has to be set by
Use nginx or apache to set the header correctly: Use nginx or apache to set the header correctly:
### Using nginx ### Using nginx
(This differs from `/docker/nginx/production.conf`) (This differs from `/docker/nginx/*.conf`)
#### Allow http and https requests
``` ```
server { server {
listen 80; listen 80;
@ -181,11 +209,6 @@ server {
location / { location / {
proxy_connect_timeout 300; proxy_connect_timeout 300;
proxy_pass http://127.0.0.1:8080; proxy_pass http://127.0.0.1:8080;
}
location /server {
proxy_connect_timeout 300;
proxy_pass http://127.0.0.1:8080;
proxy_set_header Connection "upgrade"; proxy_set_header Connection "upgrade";
proxy_set_header Upgrade $http_upgrade; proxy_set_header Upgrade $http_upgrade;
proxy_set_header X-Forwarded-for $remote_addr; proxy_set_header X-Forwarded-for $remote_addr;
@ -202,9 +225,32 @@ server {
location / { location / {
proxy_connect_timeout 300; proxy_connect_timeout 300;
proxy_pass http://127.0.0.1:8443; proxy_pass http://127.0.0.1:8443;
proxy_set_header Connection "upgrade";
proxy_set_header Upgrade $http_upgrade;
proxy_set_header X-Forwarded-for $remote_addr;
} }
}
```
#### Automatic http to https redirect:
```
server {
listen 80;
location /server { expires epoch;
location / {
return 301 https://$host:8443$request_uri;
}
}
server {
listen 443 ssl http2;
ssl_certificate /etc/ssl/certs/pairdrop-dev.crt;
ssl_certificate_key /etc/ssl/certs/pairdrop-dev.key;
expires epoch;
location / {
proxy_connect_timeout 300; proxy_connect_timeout 300;
proxy_pass http://127.0.0.1:8443; proxy_pass http://127.0.0.1:8443;
proxy_set_header Connection "upgrade"; proxy_set_header Connection "upgrade";
@ -231,6 +277,7 @@ a2enmod proxy_wstunnel
Create a new configuration file under `/etc/apache2/sites-available` (on debian) Create a new configuration file under `/etc/apache2/sites-available` (on debian)
**pairdrop.conf** **pairdrop.conf**
#### Allow http and https requests
``` ```
<VirtualHost *:80> <VirtualHost *:80>
ProxyPass / http://127.0.0.1:8080/ ProxyPass / http://127.0.0.1:8080/
@ -247,6 +294,19 @@ Create a new configuration file under `/etc/apache2/sites-available` (on debian)
RewriteRule ^/?(.*) "wws://127.0.0.1:8443/$1" [P,L] RewriteRule ^/?(.*) "wws://127.0.0.1:8443/$1" [P,L]
</VirtualHost> </VirtualHost>
``` ```
#### Automatic http to https redirect:
```
<VirtualHost *:80>
Redirect permanent / https://127.0.0.1:8443/
</VirtualHost>
<VirtualHost *:443>
ProxyPass / https://127.0.0.1:8443/
RewriteEngine on
RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteCond %{HTTP:Connection} upgrade [NC]
RewriteRule ^/?(.*) "wws://127.0.0.1:8443/$1" [P,L]
</VirtualHost>
```
Activate the new virtual host and reload apache: Activate the new virtual host and reload apache:
```shell ```shell
a2ensite pairdrop a2ensite pairdrop