damoeb / rss-proxy

RSS-proxy allows you to do create an RSS or ATOM feed of almost any website, just by analyzing just the static HTML structure.
https://rssproxy.migor.org
1.72k stars 109 forks source link

How to run rss-proxy behind an nginx reverse proxy #39

Open happening-primal opened 2 years ago

happening-primal commented 2 years ago

Great tool.

Been struggling a bit to get rss-proxy to run behind an nginx reverse proxy (SWAG). The issue that arises is that rss-proxy appears to redirect to the root directory of the web server. Runs fine without the reverse proxy (http://ip_address:3000) but is exposed to the world.

My configuration:

rss-proxy running in a docker container SWAG as the nginx reverse proxy also running in a docker container

I've used the reverse proxy to rewrite some portions of the html to route to the correct source (from / to /rss-proxy) and this gets the rendering of the page partially completed. This results in the below page source. The left panel comes up fine (Please enter the URL of the website you want an RSS Feed from) however, a call to core.js.pre-build-optimizer.js causes the right panel to fail

Http failure during parsing for https://redacted_domain_name/ Most likely the website is JavaScript generated, which is not supported by rss-proxy directly. Check the documentation for further help

Again it returns a reference back to the root directory of the web server and does not allow nginx 'sub_filter' command to make replacements.

Any help much appreciated.

================================================ nginx proxy-confs snippet:

sub_filter 'src="/'  'src="/rss-proxy/';
sub_filter_once off;

================================================ proxied page source:

<!doctype html>

RSS-proxy playground

================================================ core.js.pre-build-optimizer.js error - fetching content from web root...

ERROR Error: Uncaught (in promise): Up: {"headers":{"normalizedNames":{},"lazyUpdate":null},"status":200,"statusText":"OK","url":"https://redacted_domain_name/","ok":false,"name":"HttpErrorResponse","message":"Http failure during parsing for https://redacted_domain_name/","error":{"error":{},"text":"<!DOCTYPE html><html lang=\"en\"><meta charset=\"utf-8\"><meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"><meta name=\"viewport\" content=\"width=device-width,initial-scale=1,viewport-fit=cover\"><meta ...

Yetangitu commented 2 years ago

You can use a single domain to serve both the proxy as well as the "playground" (which runs in a development server which is not tested for security problems so make sure to put it behind a password). The following example assumes that:

Use something along these lines:

server {
    listen 80;
    server_name rssproxy.example.org;

    include /etc/nginx/snippets/enforcehttps.conf;
}

server {
    listen 443 ssl http2;
    server_name rssproxy.example.org;

    ssl_certificate /etc/letsencrypt/live/rssproxy.example.org/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/rssproxy.example.org/privkey.pem;

    location /api {
        include /etc/nginx/proxy_params;
        proxy_redirect http:// https://;
        proxy_pass http://daemon.example.org:3000;
    }
    location / {
                satisfy any;
                # allow 192.168.1.0/24; # allows internal access without password
                auth_basic "RSSProxy";
                auth_basic_user_file /etc/nginx/rssproxy.auth;
                include /etc/nginx/proxy_params;
        proxy_redirect http:// https://;
        proxy_pass http://daemon.example.org:4200;
    }
}

If you wonder what is in those referenced included files:

$ cat /etc/nginx/proxy_params 
# global proxy conf
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host:$server_port;
proxy_set_header X-Forwarded-Port $server_port;
proxy_pass_request_headers on;
$ cat /etc/nginx/snippets/enforcehttps.conf 
location / {
    return 301 https://$server_name$request_uri;
}
damoeb commented 1 year ago

Sry for the late response. Do you mind checking again with the new version 2? I added my ngix.conf reverse proxy

BachDANG commented 1 year ago

Can i run it directly from code without creating docker image?

teotimepacreau commented 2 months ago

having the same problem with version 2. still don't work with nginx-proxy-manager.

502 Bad Gateway
openresty
happening-primal commented 2 months ago

having the same problem with version 2. still don't work with nginx-proxy-manager.

502 Bad Gateway
openresty

I fixed this some time back by using a subdomain rather than a subfolder. Hope that helps.

teotimepacreau commented 2 weeks ago

fixed also for me as I was not forwarding the internal port instead of the external port in nginx. you can close the issue