Daniel15 / simple-nuget-server

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

Provide nginx example to run at subdir (example.com/nuget) #16

Open junalmeida opened 8 years ago

junalmeida commented 8 years ago

As title.

Daniel15 commented 8 years ago

You should be able to just add the subdir to all the rewrite rules, and place most of the config in your existing server block. Definitely try it out and let me know if it works :)

sunsided commented 8 years ago

In my docker image I'm actually using a script to patch the NGINX configuration on the fly based on an environment variable used on docker run:

if [ -z ${BASE_URL+false} ]
then
    echo "Using base URL: /"
else
    CONFIGFILE=/etc/nginx/conf.d/nuget.conf
    echo "Using base URL: $BASE_URL"
    perl -pi -e "s#rewrite \^(?!$BASE_URL)/#rewrite ^$BASE_URL/#g" $CONFIGFILE
    perl -pi -e "s#location = (?!$BASE_URL)/#location = $BASE_URL/#g" $CONFIGFILE
fi

It basically patchesnginx.conf from

rewrite ^/$ /index.php;

to

rewrite ^/some-configurable-path$ /index.php;