-
-
Notifications
You must be signed in to change notification settings - Fork 883
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
Allow to use multiple locations in vhost #189
Comments
Sure it is possible. Try something like this: nginx::resource::location { '/':
ensure => present,
try_files => ['$uri' '$uri/' 'index.php'],
location_cfg_prepend => {
'rewrite ^/.well-known/host-meta' => '/public.php?service=host-meta last',
'rewrite ^/.well-known/host-meta.json' => '/public.php?service=host-meta-json last;'
}
}
nginx::resource::location { '~ ^(.+?\.php)(/.*)?$':
ensure => present,
try_files => ['$1 = 404'],
fastcgi => '127.0.0.1:9000'
} I haven't test the code, hope it will compile :) |
thanks, I've tried it like this, essentialy it works but I can't get it inside server { ... } |
Try adding a vhost line. nginx::resource::location { '~ ^(.+?\.php)(/.*)?$':
ensure => present,
vhost => '...',
try_files => ['$1 = 404'],
fastcgi => '127.0.0.1:9000'
} |
I'm running into the same issue, the location is being created outside of the server block. |
Make sure nginx::resource::vhost { 'vhost_name':
ensure => present
#...
}
nginx::resource::location { 'location_name':
ensure => present,
vhost => 'vhost_name'
#...
} Also make sure you don't set the If that doesn't work can you post the full manifest you're using? |
I just ran into this too. It works fine if you have what @3flex says if you use $name as the vhost. If you don't it doesn't seem to work. Here is my example that will not put the location block inside server{...} nginx::resource::vhost { 'beta-redirect':
ensure => present,
server_name => ['beta.examle.com'],
proxy => 'http://example-beta',
location_cfg_append => {
'return 301' => 'https://beta.example.com$request_uri',
}
}
nginx::resource::vhost { 'beta.example.com':
ensure => present,
listen_port => '443',
proxy => 'http://example-beta',
ssl => true,
ssl_cert => '/etc/example/ssl/beta.example.com.crt',
ssl_key => '/etc/example/ssl/beta.example.com.key',
location_cfg_append => {
'proxy_set_header X-Forwarded-Protocol' => 'https',
'proxy_set_header Host' => '$http_host',
'proxy_set_header X-Real-IP' => '$remote_addr',
'proxy_set_header X-Scheme' => '$scheme',
}
}
nginx::resource::location {'beta.example.com-static':
vhost => 'beta.example.com',
ensure => 'absent',
location => '/static',
proxy => 'http://example-beta',
location_cfg_prepend => {
'expires' => 'max',
'add_header Cache-Control' => 'public',
}
} Not sure if the rest of my config is the best way to do it so I am welcome to input on that as well :) |
I just ran into the same problem when using ssl and spent way too long figuring it out, assuming it was a bug. (In a way I still think it is.) Locations that belong in an SSL vhost need the In the case of @sherzberg's config the solution would be to add this to the location: ssl => true,
ssl_only => true, |
@emning thanks for the tip. Just implemented this and it works great! |
@emning @sherzberg I added a section the README regarding SSL and vhost/location relationships, could you let me know if this clarifies things at all? Thanks! https://github.com/jfryman/puppet-nginx#ssl-configuration |
Looks very good to me, @3flex. I would say this issue can be closed. Well done! |
@jacek-berlin would you consider closing this if there's nothing outstanding? |
@3flex looks like exactly what I needed! Thanks for taking the time to add it to the docs! |
I would say this behavior is a bug. Having the module throw an error instead would be great. |
I'm closing this, as it looks like the original issue was addressed. @devopsdevon would you open a new issue for the behaviour you described? Thanks! |
Hello,
Please correct me if I am wrong, now there is no possibility to declare multiple locations in one vhost ?
Example output configuration:
http://doc.owncloud.org/server/5.0/admin_manual/installation/installation_others.html
The text was updated successfully, but these errors were encountered: