I'm trying to configure a proxy to public websites (origin) with the addition of my script to the head element of the HTML. The way I can access https://proxy.mywebsite.info/?script=www.myscript.com/a.js&origin=google.com and get the origin website with my script injected.
The injection part works fine but somehow any public website which is loaded shows me errors like I'm doing the proxying wrong.
Out of ideas after hours of trying different nginx.conf settings.
proxy.mywebsite.info points to my machine 127.0.0.1.
The error I'm getting from nginx
[error] 2203#2203: *272 invalid URL prefix in "https://", client: 127.0.0.1, server: proxy.mywebsite.info, request: "GET /favicon.ico HTTP/1.1", host: "proxy.mywebsite.info"
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
}
http {
server {
listen 443 ssl;
server_name proxy.mywebsite.info;
ssl_certificate /etc/ssl/certs/proxy.mywebsite.info.crt;
ssl_certificate_key /etc/ssl/private/proxy.mywebsite.info.key;
keepalive_timeout 70;
proxy_ssl_server_name on;
proxy_ssl_session_reuse off;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
root /var/www/html;
index index.html;
access_log /tmp/access.log;
error_log /tmp/error.log;
location / {
resolver 8.8.8.8;
proxy_pass https://$arg_origin;
proxy_read_timeout 10;
proxy_set_header Host $host;
proxy_set_header Accept-Encoding "";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Connection "Keep-Alive";
proxy_set_header Proxy-Connection "Keep-Alive";
proxy_ssl_name $host;
proxy_ssl_server_name on;
proxy_ssl_session_reuse off;
sub_filter '<head>' '<head><script src="https://$arg_script"></script>';
sub_filter_once on;
}
}
}
Any help is well appreciated.