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

Running behind reverse proxy #19

Open
nivinj opened this issue Aug 6, 2019 · 5 comments
Open

Running behind reverse proxy #19

nivinj opened this issue Aug 6, 2019 · 5 comments

Comments

@nivinj
Copy link

nivinj commented Aug 6, 2019

When running LiGet behind a reverse proxy, would be great if there was a way to specify the external URL to LiGet so it can be returned in the responses. In my case, I have LiGet running on internalserver:9011 and I have apache reverse proxying nuget.mycompany.com to internalserver:9011.

However in all the responses from Liget the internal (hidden) URL is used. e.g.:
{"version":"3.0.0","resources":[{"@id":"http://internalserver:9011/api/v2/package"...

Ideally should return:
{"version":"3.0.0","resources":[{"@id":"http://nuget.mycompany.com/api/v2/package"...

@nivinj
Copy link
Author

nivinj commented Aug 6, 2019

Probably fixed by accepting an environment variable for proxy endpoint, and using this to build the URL in CarterUrlExtensions.cs

public static string AbsoluteUrl(this HttpRequest request, string relativePath)

public static Uri GetUri(this HttpRequest request)

@viceice
Copy link

viceice commented Sep 18, 2019

@nivinj Im using it behind a traefik proxy, which is working fine. Maybe you have to check the passed HTTP headers

@plemanach
Copy link

I passing an env variable to use behind a proxy

docker run -ti -d --env https_proxy=http://myproxy.com

@efess
Copy link

efess commented Feb 4, 2020

If you're using nginx, make sure you're passing the host header as well - since that's what LiGet uses to resolve the absolute URL

proxy_set_header Host            $host;
proxy_set_header X-Forwarded-For $remote_addr;

edit: just a reminder - clear your local nuget http cache if you update this, since nuget will cache the index.json file.

@Dunge
Copy link

Dunge commented Feb 7, 2023

Anyone know how to do this via a kubernetes ingress-nginx config and route a subpath to the service?

I tried using a generic solution I see in other articles using the rewrite-target annotation to rewrite the url, but the returning xml document doesn't include the sub path.

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: http-ingress
  annotations:
    nginx.ingress.kubernetes.io/enable-cors: "true"
    nginx.ingress.kubernetes.io/rewrite-target: /$2
spec:
  ingressClassName: public
  rules:
  - host: mydomain.com
    http:
      paths:
      - path: /nuget(/|$)(.*)
        pathType: Prefix
        backend:
          service:
            name: liget
            port:
              number: 9011

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

5 participants