Daniel15 / simple-nuget-server

A very simple PHP NuGet server
MIT License
116 stars 43 forks source link

Apache config would be nice #20

Closed bkraul closed 7 years ago

bkraul commented 7 years ago

Thanks for your project. Is there anyway for you to attach an apache configuration example, like you did the nginx one?

I am having trouble translating the rewrite rules for use in my .htaccess.

Daniel15 commented 7 years ago

I haven't had a chance to look at it in detail yet, but @JunielKatarn was working on some changes for Apache compatibility, including updating the rewrite rules: https://github.com/JunielKatarn/simple-nuget-server/commits/apache. There was also an older pull request for it at #3 but it got stale.

bkraul commented 7 years ago

Right on man, that was some lightning-fast reply. Thanks.

JunielKatarn commented 7 years ago

Hi @bkraul. I recently worked on an apache port. Unfortunately, it's not only about the .htaccess configuration file. Some changes need to be made to the PHP code base.

If you checkout the 'apache' branch of my fork, it should work almost out of the box. Just copy the .htaccess.example file into .htaccess and follow the instructions there.

bkraul commented 7 years ago

Thanks @JunielKatarn, will give that a try.

bkraul commented 7 years ago

Hey guys, I hit a little snag with @JunielKatarn 's apache branch, but I cannot post an issue on his fork. I was able to successfully set the server up and, successfully push a package to it. The package shows up in the Nuget Package manager in VisualStudio (which is what I am using to consume it), but when I tried to download it, I get an 'Operation failed. Archive size cannot be zero'.

I went ahead and tried the same thing directly on a browser using the call that the package manager sends to the server (GET request), and the file I end up downloading is empty. I can verified that the package I pushed is an actual file. Any idea why I am getting an empty file?

bkraul commented 7 years ago

Apparently this is due to the way the file is downloaded, using the X-Accel-Redirect header, which is not available in Apache. I am trying to implement X-Sendfile (after installing mod_xsendfile). Will report on what I find.

If X-Sendfile does not work, I guess the old fashioned readfile() can be used.

Daniel15 commented 7 years ago

Yeah, X-Sendfile should work in Apache once you install the module. readfile() would work, it's just not as efficient as letting the webserver do it itself (web servers are extremely good at handling static files, particularly around caching / cache validation)

JunielKatarn commented 7 years ago

Hi @bkraul. I've enabled issues on my fork. You can raise one there if you want.

I didn't implement X-SendFile logic because I didn't want to make that "non-core" module mandatory. I'm not submitting a PR yet, because my changes may potentially break NGinx deployments, and I haven't had a chance to test that configuration.

bkraul commented 7 years ago

Hey guys, X-Sendfile worked just fine. There is a way to build a logic detection, such as whether we have Nginx or Apache, and then if the mod_xsendfile is enabled, failing back to readfile. I wonder if this would be beneficial.

The other option would be to build this into the Config class (config.php) in order to choose a download method, defaulting toX-Accel-Redirect, but allowing to do X-Sendfile or readfile(). The download.php would then look at this and determine what to use.

Daniel15 commented 7 years ago

Yeah, adding it as a setting in the config class sounds good to me! 😄

samangh commented 7 years ago

Thank you @Daniel15 and @bkraul for your work on this.

Did you guys manage to fix the Apache download issues?

Daniel15 commented 7 years ago

Sorry, I haven't used Apache in a long time so I'm not sure what would need to be done.