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

feat(nginx-website): allow setting redirections #1332

Conversation

lemeurherveCB
Copy link
Contributor

@lemeurherveCB lemeurherveCB commented Sep 12, 2024

This PR allows defining redirections (with return, preferable in most cases to rewrite) so we can for example avoid breaking existing (old.)stats.jenkins.io URLs which pointed to files on GitHub but are not served by the new frontend, used by far more than we/I though initially.

Ref:

Example of usage

values.yaml:

nginx:
  serverName: localhost
  slashLocation:
    root: /usr/share/nginx/html
    index: index.html index.htm
    autoindex: "on"
    ## Uncomment to enable try_files directive
    # tryFiles: $uri /index.html
  redirections: {}
    - location: /jenkins-stats
      returnedCode: 301
      destination: https://raw.githubusercontent.com/jenkins-infra/infra-statistics/gh-pages/
    - location: /plugin-installation-trend
      returnedCode: 301
      destination: https://raw.githubusercontent.com/jenkins-infra/infra-statistics/gh-pages/
    - location: /pluginversions
      returnedCode: 301
      destination: https://raw.githubusercontent.com/jenkins-infra/infra-statistics/gh-pages/

Resulting nginx config:

    server {
      listen       80;
      server_name  localhost;
      location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
        autoindex on;
      }
      location /jenkins-stats {
        return 301 https://raw.githubusercontent.com/jenkins-infra/infra-statistics/gh-pages/$request_uri;
      }
      location /plugin-installation-trend {
        return 301 https://raw.githubusercontent.com/jenkins-infra/infra-statistics/gh-pages/$request_uri;
      }
      location /pluginversions {
        return 301 https://raw.githubusercontent.com/jenkins-infra/infra-statistics/gh-pages/$request_uri;
      }
    }

Copy link
Member

@timja timja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may work, but the safer option would be new stats app to server these files directly.

If it can't be done quickly then the site should be rolled back (although old should be kept to not breaking people who have migrated there)

## Example:
# - location: /plugin-installation-trend
# returnedCode: 301
# destination: https://raw.githubusercontent.com/jenkins-infra/infra-statistics/gh-pages/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't the same API and may still cause breaking changes.

  1. There's no guarantee that consumers will follow redirects
  2. raw.githubusercontent returns a content-type of text/plain which may break consumers

@lemeurherveCB
Copy link
Contributor Author

the safer option would be new stats app to server these files directly.

I agree with that and the other points you mentioned, but the issue with serving these files directly from our service is that we don't know (and can't AFAIK) how much outbound bandwidth it could represent.
Depending on the external consumers that might be too costly.

@timja
Copy link
Member

timja commented Sep 12, 2024

the safer option would be new stats app to server these files directly.

I agree with that and the other points you mentioned, but the issue with serving these files directly from our service is that we don't know (and can't AFAIK) how much outbound bandwidth it could represent. Depending on the external consumers that might be too costly.

If thats a concern is there any reason we moved off GitHub pages?
its a fully static site isn't it?

@dduportal
Copy link
Contributor

This may work, but the safer option would be new stats app to server these files directly.

If it can't be done quickly then the site should be rolled back (although old should be kept to not breaking people who have migrated there)

+1 with @timja . This should justify a rollback and a re-architecturing of the model used if bandwidth is a problem.

@dduportal
Copy link
Contributor

(although old should be kept to not breaking people who have migrated there)

@timja @lemeurherveCB Just a point about the GitHub Pages: it only accepts a single CNAME.
Looks like it is a problem here as we have to choose between old.stats.jenkins.io or stats.jenkins.io if we rollback.

I'll continue in jenkins-infra/helpdesk#4132

@dduportal
Copy link
Contributor

Closed by jenkins-infra/stats.jenkins.io#168 (not needed anymore)

@dduportal dduportal closed this Sep 18, 2024
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

Successfully merging this pull request may close these issues.

3 participants