Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sorry about noob question :) #18

Closed
zaywalker opened this issue Sep 18, 2018 · 4 comments
Closed

Sorry about noob question :) #18

zaywalker opened this issue Sep 18, 2018 · 4 comments

Comments

@zaywalker
Copy link

zaywalker commented Sep 18, 2018

hello again!
It's hard to figure the custom configuration without knowledge about linux and nginx. T_T
I've attached some server successfully like home assistant with custom confuguration, but now I'm hit the wall to handle web terminal called "butterfly".
currently, it's fine to run with redirection host and i'm now trying to do with reverse proxy.
the instruction is
https://github.com/paradoxxxzero/butterfly/wiki/Butterfly-with-nginx-reverse-proxy-and-https

server {
    listen       80;
    listen       443 ssl;

    listen       [::]:80;
    listen       [::]:443 ssl;

    server_name  example.com;
    ssl_certificate certs/example.com.chained.crt;
    ssl_certificate_key certs/example.com.key;

    ssl_protocols       TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers         HIGH:!aNULL:!MD5;

    charset utf-8;

    access_log  /var/log/nginx/$host.access.log;

    client_max_body_size 20M;

    root   /var/www/;
    index  index.html index.htm;

    if ($ssl_protocol = "") {
        return 301 https://$http_host$request_uri;
    }

    location / {
        try_files $uri $uri/ =404;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    location /butterfly {
        auth_basic "Authentication required";
        auth_basic_user_file /etc/nginx/.htpasswd;

        rewrite ^/butterfly/?(.*) /$1 break;
        proxy_pass http://127.0.0.1:57575;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
        proxy_set_header Origin "$scheme://$host";

        proxy_connect_timeout 7d;                                                                                                              
        proxy_send_timeout 7d;                                                                                                                 
        proxy_read_timeout 7d;

        sub_filter_once off;

        sub_filter_types text/css text/xml application/javascript;
        sub_filter /style.css '/butterfly/style.css';
        sub_filter /static '/butterfly/static';
        sub_filter /ws '/butterfly/ws';
        sub_filter /themes '/butterfly/themes';
        sub_filter location.pathname '"/"';
    }

    rewrite ^/theme/?(.*)/butterfly/?(.*) /butterfly/theme/$1/$2 permanent;
}

this instruction is for cname? domain like aaa.bbb.ccc/butterfly

but i'm trying to make subdomain butterfly.bbb.ccc

when I try to do location / , proxy status turns offline...

any help will be great for me!

thanks advance!

@jc21
Copy link
Member

jc21 commented Sep 18, 2018

Wow that's a lot of unnecessary crap they want you to do.

You should only need this location block, without all the ssl, redirections and basic authentication that the NPM will already handle. Even then, the only reason you need this is because of the websocket upgrade that is mixed in with all of it.

location ~ .*/ws.* {
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_http_version 1.1;
    proxy_pass http://$server:$port;
    proxy_connect_timeout 7d;
    proxy_send_timeout 7d;
    proxy_read_timeout 7d;
}

Give that a go. I'm not prepared to install butterfly to test it out though :)

@zaywalker
Copy link
Author

@jc21 Super thanks for the reply! I've tried the location block, unfortunatly, I got black screen like before. Even restart NPM docker.
But, I've learn some clue about
~ .*/ws.*
I'll try do this another way!
Thanks eyery time!

@jc21
Copy link
Member

jc21 commented Oct 1, 2018

For future reference, I added another setting for Proxy Hosts in version 2.0.3 you can use for any hosts that need websocket upgrades. Just turn on "Allow Websocket HTTP Upgrades" and hopefully everything works without the need for advanced config.

@jc21 jc21 closed this as completed Oct 1, 2018
@zaywalker
Copy link
Author

working great!!! thanks!

@dounoit dounoit mentioned this issue Aug 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants