kanreisa / reichat

A lovely paint chat application like a PaintChatApp built with Node.
https://r2.ag/reichat-preview/
MIT License
184 stars 23 forks source link

can't reverse proxy from subfolder #10

Open miaulightouch opened 7 years ago

miaulightouch commented 7 years ago

javascript load object with absolute path not relative path, and cause problem.

ex: I set reverse proxy to reichat in example.com/paint, like below

    location /paint/ {
        proxy_set_header  X-Real-IP        $remote_addr;
        proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;
        proxy_set_header  Host             $http_host;
        proxy_set_header  X-Forwarded-Proto $scheme;
        proxy_pass        http://127.0.0.1:10133/;
        proxy_redirect    off;
    }

but script still ask the file from root, like: example.com/socket-io/somefile.js, not: example.com/paint/socket-io/somefile.js

hidekuro commented 7 years ago

REICHAT's src is written starts with "//". This is a good way as it is protocol independent. You can use the rewrite directive to solve it.

location /paint/ {
    rewrite ^/paint(/.*)$ $1 last;
    # any other proxy directives...
}
miaulightouch commented 7 years ago

still no luck, as I said, when browser calling socket-io, it still call from host root.

and, your rewrite rule is routing /paint/ to /, it will show the same thing at /index.htm

Add new subdomain for reichat instance is my personal recommend, thank you.