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

[OTHER] how to set a subpath like "example.com/it_tool/xxxx" #1062

Open
momomobinx opened this issue May 11, 2024 · 15 comments
Open

[OTHER] how to set a subpath like "example.com/it_tool/xxxx" #1062

momomobinx opened this issue May 11, 2024 · 15 comments
Assignees

Comments

@momomobinx
Copy link

how to set a subpath like "example.com/it_tool/xxxx"

@ghost
Copy link

ghost commented May 13, 2024

and i

@GAS85
Copy link

GAS85 commented Jun 13, 2024

I found a workaround with apache2 (same configuration could be implemented in nginx), basically you need to do some rewrites, but would be nice if BASEPATH can be implemented as part of configuration.

Redirect 301 "/it-tools" "/it-tools/"
        <Location /it-tools/>
                ProxyPreserveHost On
                ProxyPass http://localhost:9070/ retry=0 timeout=5
                ProxyPassReverse http://localhost:9070/
                RequestHeader set Connection ""

                AddOutputFilterByType INFLATE;SUBSTITUTE text/html application/javascript
                SubstituteMaxLineLength 2000K
                Substitute "s|href=\"|href=\"/it-tools/|inq"
                Substitute "s|src=\"|src=\"/it-tools|inq"
                Substitute "s|\"assets/|\"it-tools/assets/|inq"
                Substitute "s|BASE_URL:\"/\"|BASE_URL:\"/it-tools/\"|inq"
        </Location>

You can find example here: https://sitnikov.eu/it-tools/
It is not perfect:

  1. Main page shows 404 instead of "main page", but if you click on "home" it will be fine. Solved
  2. URL will be updated without basepath, but in a fact all scripts are loaded from the correct place.
    изображение

@AndrewDi
Copy link

same request

@doubleJazzCat
Copy link

+1

@sharevb
Copy link
Contributor

sharevb commented Feb 23, 2025

Hi @doubleJazzCat, @AndrewDi, @GAS85, @momomobinx, related to #423, implemented in my fork, if you arr interested in up to date version of it-tools, I made kind of a fork here : https://github.com/sharevb/it-tools (https://sharevb-it-tools.vercel.app/ and docker images https://github.com/sharevb/it-tools/pkgs/container/it-tools)

@doubleJazzCat
Copy link

Hi @doubleJazzCat, @AndrewDi, @GAS85, @momomobinx, related to #423, implemented in my fork, if you arr interested in up to date version of it-tools, I made kind of a fork here : https://github.com/sharevb/it-tools (https://sharevb-it-tools.vercel.app/ and docker images https://github.com/sharevb/it-tools/pkgs/container/it-tools)

nice guy, may the force be with u

@GAS85
Copy link

GAS85 commented Feb 25, 2025

@sharevb I did test it twice and seems not working for me...

@imantoniojuan
Copy link

Hi @GAS85, how did you solve the 404 on the main page?
@sharevb, I have tested your docker image as well but I get the 404 on main page too.

I need to click the Home icon in order to populate the tools list.

@GAS85
Copy link

GAS85 commented Apr 3, 2025

Hey, actually configuration above was updated, Substitute of BASE_URL makes the trick. If it does not work for you, please provide your configuration here.

@imantoniojuan
Copy link

imantoniojuan commented Apr 3, 2025

@GAS85 thanks for clarifying. I got it working through my nginx.

rewrite ^/it-tools(/.*)$ $1 break;

sub_filter 'it-tools.tech' 'mydomain.com/it-tools';
sub_filter "/assets/" "/it-tools/assets/";
sub_filter "\"assets/" "\"it-tools/assets/";
sub_filter "/manifest.webmanifest" "/it-tools/manifest.webmanifest";
sub_filter "/sw.js" "/it-tools/sw.js";
sub_filter "/android-chrome" "/it-tools/android-chrome";
sub_filter "/favico" "/it-tools/favico";
sub_filter "BASE_URL:\"/\"" "BASE_URL:\"/it-tools/\"";

sub_filter_once off;
sub_filter_types *;

However, some things are broken like ASCII Art Text Generator, Adding to Favourites inside each tool and Web App. I think its acceptable now though.

@sharevb
Copy link
Contributor

sharevb commented Apr 5, 2025

Hi @GAS85 and @imantoniojuan , I just integrated things related to #423
I will try to release a docker image at "/it-tools/" BASE_URL
Also, latest docker image use a nginx unpriveledged so on port 8080
And finally, I am not a specialist of nginx and so I took thins here : #461

@GAS85
Copy link

GAS85 commented Apr 5, 2025

However, some things are broken like ASCII Art Text Generator, Adding to Favourites inside each tool and Web App. I think its acceptable now though.

You right... I will check what is wrong there. I thought I did test it all.

@sharevb
Copy link
Contributor

sharevb commented Apr 6, 2025

Hi @ , implemented BASE_URL (and config sample) in my fork, and published a baseurl-it-tools tag

Detailed explaination to make it work: https://github.com/sharevb/it-tools?tab=readme-ov-file#docker-compose-for-hosting-in-a-it-tools-subfolder and https://github.com/sharevb/it-tools?tab=readme-ov-file#docker-compose-for-hosting-in-a-it-tools-subfolder

@GAS85
Copy link

GAS85 commented Apr 7, 2025

However, some things are broken like ASCII Art Text Generator, Adding to Favourites inside each tool and Web App. I think its acceptable now though.

ASCII Art Text Generator does not work for now, it is nothing to do with current solution.

Everything else is working now.

@sharevb
Copy link
Contributor

sharevb commented Apr 13, 2025

Hi @GAS85, latest version of baseurl-it-tools tag should make ascii art text generator 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

7 participants