bagetter / BaGetter

A lightweight NuGet and symbol server
https://www.bagetter.com
MIT License
166 stars 38 forks source link

Document usage for reverse proxy #143

Closed xafero closed 3 weeks ago

xafero commented 1 month ago

Is your feature request related to a problem? Please describe.

I needed to host BaGetter behind an Nginx reverse proxy and wasted some time on it.

Describe the solution you'd like

Document the usage of PathBase in the appsettings (I only read it in the source code directly), in case it has to have a path like "/nuget". Otherwise the main site's HTML will load but every resource and subpath will error out.

Describe alternatives you've considered

None.

Additional context

None.

xafero commented 1 month ago

It could be directly under ApiKey on https://www.bagetter.com/docs/configuration ...

seriouz commented 1 month ago

Hi @xafero can you give me more detail what you wanted to configure and what you in the end actually configured?

xafero commented 1 month ago

I simply did ~/bagetter/appsettings.json "PathBase": "/nuget"

but found that out myself by reading your Configuration class in the source code.

If you had it documented on the configuration doc site, I would have been faster and not tried to fork the project (to add the line UsePathBase(options) which is gladly already there).

xafero commented 1 month ago

Hi @xafero can you give me more detail what you wanted to configure and what you in the end actually configured?

Otherwise, please show me on which page that behaviour is documented (on https://www.bagetter.com/docs/configuration I can't find it).

seriouz commented 1 month ago

So you wanted to call the BaGetter server by something like this https://my.domain/nuget through Nginx?

xafero commented 1 month ago

Yes

AlienJust commented 1 month ago

I have drop-in config file for nginx like:

server {
    listen 443 ssl http2;
    server_name  nuget.xyz.ru;
    ssl_certificate /etc/letsencrypt/live/nuget.xyz.ru-0001/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/nuget.xyz.ru-0001/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf;
    # Prevent nginx HTTP Server Detection
    #server_tokens off

    # passing /api to baget's api path
    location ^~ / {
       proxy_pass http://127.0.0.1:6580/;
       proxy_buffering off;
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-Host $host;
       proxy_set_header X-Forwarded-Port $server_port;
       proxy_set_header Host $http_host;
       proxy_set_header Upgrade $http_upgrade;
       proxy_set_header Connection $proxy_connection;
       proxy_set_header X-Forwarded-Host $the_host;
       proxy_set_header X-Forwarded-Proto $the_scheme;
    }
}
xafero commented 1 month ago

Hey, I already solved my issue days ago and of course wrote a nginx config. I'm talking about Bagetter here and its missing documentation(!).

xafero commented 1 month ago

Some people don't want Stackoverflow/Github to do their homework, but instead want to improve the situation for others by simply asking the project maintainer to add some few lines and document a common use case. Hard to believe maybe.

xafero commented 1 month ago

I have drop-in config file for nginx like:

server {
    listen 443 ssl http2;
    server_name  nuget.xyz.ru;
    ssl_certificate /etc/letsencrypt/live/nuget.xyz.ru-0001/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/nuget.xyz.ru-0001/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf;
    # Prevent nginx HTTP Server Detection
    #server_tokens off

    # passing /api to baget's api path
    location ^~ / {
       proxy_pass http://127.0.0.1:6580/;
       proxy_buffering off;
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-Host $host;
       proxy_set_header X-Forwarded-Port $server_port;
       proxy_set_header Host $http_host;
       proxy_set_header Upgrade $http_upgrade;
       proxy_set_header Connection $proxy_connection;
       proxy_set_header X-Forwarded-Host $the_host;
       proxy_set_header X-Forwarded-Proto $the_scheme;
    }
}

You have "passing api" but never pass "api". I guess you just copied without checking.

Regenhardt commented 3 weeks ago

Thanks for the issue @xafero . Would you look at the merge request and decide if that addition would have helped you?

xafero commented 3 weeks ago

Thanks