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

could not add path via nginx reverse proxy #20

Open
smilence86 opened this issue Jun 23, 2022 · 11 comments
Open

could not add path via nginx reverse proxy #20

smilence86 opened this issue Jun 23, 2022 · 11 comments

Comments

@smilence86
Copy link

smilence86 commented Jun 23, 2022

I don't want to use subdomain to serve it, instead add a custom path into url, such as https://example.com/share.

my nginx config is looks like:

location /share/ {
        proxy_read_timeout 60m;
	proxy_set_header Host $host;
	proxy_set_header X-Forwarded-Proto https;
	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	proxy_set_header X-Real-IP $remote_addr;
	proxy_pass http://127.0.0.1:8000/;
}

location /_h5ai/ {
        proxy_pass http://127.0.0.1:8000/h5ai;
}

It won't show files in browser, what am I wrong or something missing? please help me.

@awesometic
Copy link
Owner

Hi,

I think you can get that by the following configs.

location /share {
    return 301 $scheme://$host/dokuwiki/;
}

location ^~ /share/ {
    proxy_read_timeout 60m;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Proto https;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_pass $http://127.0.0.1:8000;

    rewrite /share(.*) $1 break;
}

You don't need to add location /_h5ai/ in your reverse proxy configure because as we know the docker app creates a web server independently.

Not tested, sorry, but it is worth trying.

@smilence86
Copy link
Author

Seems not work, some static files are 404 error:

image

Something Need explain further, The port 8000 is h5ai listening by docker container, There are few other services running behind nginx as well:

location /speedtest/ {
        auth_basic "input password";
	auth_basic_user_file /etc/nginx/conf.d/pwd.db;
        proxy_read_timeout 60m;
	proxy_set_header Host $host;
	proxy_set_header X-Forwarded-Proto https;
	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Connection "upgrade";
	proxy_redirect off;
	proxy_pass http://127.0.0.1:8686/;
}

location /adg/ {
        proxy_read_timeout 60m;
	proxy_set_header Host $host;
	proxy_set_header X-Forwarded-Proto https;
	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Connection "upgrade";
	proxy_redirect off;
	proxy_pass http://127.0.0.1:3000/;
}

location /wireguard/ {
        proxy_read_timeout 60m;
	proxy_set_header Host $host;
	proxy_set_header X-Forwarded-Proto https;
	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Connection "upgrade";
	proxy_redirect off;
	proxy_pass http://127.0.0.1:51821/;
}

I want to use one domain cert to manager all services by tls.

@awesometic
Copy link
Owner

awesometic commented Jun 23, 2022

Ah, you were right, seems we need to specify a location for _h5ai directory.

Then how about adding this one?

location ^~ /share/_h5ai {
    proxy_read_timeout 60m;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Proto https;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_pass $http://127.0.0.1:8000;

    rewrite /share(.*) $1 break;
}

Maybe rewrite is not needed.. But don't know.

If you can't get even with the new configuration, I will test it on my side soon.

@smilence86
Copy link
Author

Also 404

location ^~ /share/ {
        proxy_read_timeout 60m;
		proxy_set_header Host $host;
		proxy_set_header X-Forwarded-Proto https;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_set_header X-Real-IP $remote_addr;
		proxy_pass http://127.0.0.1:8000/;
	}

    location ^~ /share/_h5ai {
        proxy_read_timeout 60m;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-Proto https;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_pass http://127.0.0.1:8000;

        rewrite /share(.*) $1 break;
    }

@awesometic
Copy link
Owner

Sorry, for the last try, how about this one?

    location ^~ /share/_h5ai {
        proxy_read_timeout 60m;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-Proto https;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_pass http://127.0.0.1:8000/_h5ai;

        rewrite /share(.*) $1 break;
    }

I appended /_h5ai to the proxy_pass property.

@smilence86
Copy link
Author

smilence86 commented Jun 23, 2022

not work, 404.

image

@awesometic
Copy link
Owner

Will test on my side 😅

@smilence86
Copy link
Author

Will test on my side sweat_smile

Thanks for your help.

@smilence86
Copy link
Author

Hello, any updates for this?

@awesometic
Copy link
Owner

awesometic commented Jul 1, 2022

Hi,

I tried but couldn't succeed yet. I think it is very difficult because each URL indicates each file, and this is managed by a PHP index file under /_h5ai directory.
Sorry, 😅
Anyone who can know how to this configure?

@smilence86
Copy link
Author

Okay, Thanks, I'll use subdomain first before that could work.

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