Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
router:proxy_chain [2025/02/04 11:00] – willy | router:proxy_chain [Unknown date] (current) – removed - external edit (Unknown date) 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | The idea is having TWO NGINX proxy linked by a WireGuard channel. | ||
- | |||
- | ==== External NGINX ==== | ||
- | |||
- | wireshark setup | ||
- | |||
- | Internal server config into **/ | ||
- | <file - wg0.conf> | ||
- | [Interface] | ||
- | PrivateKey = << here my private key >> | ||
- | Address = 10.100.0.1/ | ||
- | |||
- | [Peer] # this is external server | ||
- | PublicKey = << here external public key >> | ||
- | Endpoint = << external server IP >>: | ||
- | AllowedIPs = 10.100.0.2/ | ||
- | PersistentKeepAlive = 25 | ||
- | </ | ||
- | |||
- | External server config into **/ | ||
- | <file - wg0.conf> | ||
- | [Interface] | ||
- | PrivateKey = << external server private key >> | ||
- | Address = 10.100.0.2/ | ||
- | ListenPort = 5790 | ||
- | |||
- | [Peer] # this is internal server | ||
- | PublicKey = << internal server public key >> | ||
- | #Endpoint = # internal server has no public IP, leave this commented. | ||
- | AllowedIPs = 10.100.0.1/ | ||
- | PersistentKeepAlive = 25 | ||
- | </ | ||
- | |||
- | Start both on boot, so on both servers: | ||
- | <code bash> | ||
- | ln -s / | ||
- | rc-update add wg-quick.wg0 default | ||
- | / | ||
- | </ | ||
- | |||
- | |||
- | ==== External NGINX ==== | ||
- | |||
- | <file - nginx.conf> | ||
- | server { | ||
- | server_name *.mydomain.com; | ||
- | listen 4443 ssl; | ||
- | include proxy-chain.conf; | ||
- | ssl_certificate / | ||
- | ssl_certificate_key / | ||
- | } | ||
- | |||
- | server { | ||
- | server_name otherdomain.whatever; | ||
- | listen 4443 ssl; | ||
- | include proxy-chain.conf; | ||
- | ssl_certificate / | ||
- | ssl_certificate_key / | ||
- | } | ||
- | </ | ||
- | |||
- | <file - proxy-chain.conf> | ||
- | location / { | ||
- | proxy_pass https:// | ||
- | } | ||
- | |||
- | include / | ||
- | ssl_dhparam / | ||
- | proxy_set_header | ||
- | proxy_set_header | ||
- | proxy_set_header | ||
- | proxy_set_header | ||
- | proxy_set_header X-Forwarded-Proto $scheme; | ||
- | proxy_set_header X-Forwarded-Host $server_name; | ||
- | proxy_set_header X-Forwarded-Ssl on; | ||
- | proxy_set_header Upgrade $http_upgrade; | ||
- | proxy_set_header Connection " | ||
- | proxy_http_version 1.1; | ||
- | </ | ||
- | |||
- | ==== Certificates ==== | ||
- | |||
- | Needs to be shared between the internal server and the external server. You cannot use certbot on both, because ports 80&443 of external are redirected to the internal and certbot on external would not work. | ||
- | |||
- | So, on internal zip che certs after any update, edit crontab like: | ||
- | < | ||
- | 47 5 * * * / | ||
- | 31 16 * * * / | ||
- | </ | ||
- | |||
- | On external, copy that file over and replace certs, again in crontab: | ||
- | < | ||
- | 10 6 * * * sftp -P 5022 user@127.0.0.1:/ | ||
- | 50 16 * * * sftp -P 5022 user@127.0.0.1:/ | ||
- | </ | ||
- | |||
- | Of course, add the external root SSH public key to user file / | ||
- | |||