mikexstudios / dokku-nginx-alt

Alternative nginx plugin for dokku. Supports multiple domains and custom nginx.conf.
35 stars 26 forks source link

Redirect non-www to www #5

Closed glebm closed 10 years ago

glebm commented 10 years ago

I am trying to set up a redirect like this:

# Redirect site.com to www.site.com
server {
  listen [::]:80;
  listen 80;
  server_name ${SERVER_NAME_SANS_WWW};
  return 301 http://${SERVER_NAME}$request_uri;
}

How can I do this without hardcoding the non-www URL? I tried adding a dokku config var, but it does not seem to work even with user-env-compile.

mikexstudios commented 10 years ago

There's no way of doing this right now. But I like your idea of having access to configuration variables. Can you try modifying post-deploy to source the app's ENV file... let's say around line 22?

source $APP_PATH/ENV

Then see if you can access your config variables in the templates. I think it should work but do not have the time to test it out right now.

Thanks!

mikexstudios commented 10 years ago

Thanks for the PR.