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

How did you implement the yabs.sh website redirect? #39

Closed
TheBestPessimist opened this issue Jun 17, 2022 · 1 comment
Closed

How did you implement the yabs.sh website redirect? #39

TheBestPessimist opened this issue Jun 17, 2022 · 1 comment

Comments

@TheBestPessimist
Copy link

Hey,
I see that running wget -vO- yabs.sh does a redirect to the raw github link, however opening yabs.sh directly in the browser does a redirect to the repo. Running in powershell on windows also redirects to normal github repo, not the raw page.

Do you use wget's user agent as discriminator or what else? Is there a repo showing this setup?

Thanks

@TheBestPessimist TheBestPessimist changed the title How did you make yabs.sh redirect? How did you implement the yabs.sh website redirect? Jun 17, 2022
@masonr
Copy link
Owner

masonr commented Jun 18, 2022

Hey there!

Yes -- I'm using nginx and detecting the user agent that's initiating the request. Here is the complete config, nothing fancy:

server {
        listen 80;
        server_name yabs.sh;

        if ( $http_user_agent ~ 'curl' ) {
                return 301 https://raw.githubusercontent.com/masonr/yet-another-bench-script/master/yabs.sh;
        }

        if ( $http_user_agent ~ 'Wget' ) {
                return 301 https://raw.githubusercontent.com/masonr/yet-another-bench-script/master/yabs.sh;
        }

        return 301 https://github.com/masonr/yet-another-bench-script;
}

Let me know if you have any other questions.

Cheers,
-Mason

@masonr masonr closed this as completed Jun 18, 2022
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