Skip to content
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

Fixed long names virtual hosts... #233

Merged
merged 11 commits into from
Jan 23, 2014
Merged

Fixed long names virtual hosts... #233

merged 11 commits into from
Jan 23, 2014

Conversation

abraham1901
Copy link
Contributor

Fixed long names virtual hosts, such as nginx::resource::vhost { 'name1.domainname.org name2.domainname.org': }
Add example nginx::vhost with HTTPS FastCGI and redirection of HTTP
Add location_custom_cfg_prepend & location_custom_cfg_append. Used for logical structures such as if.
Example:
location_custom_cfg_prepend => [
'if (-f $document_root$fastcgi_script_name){
set $fsn $fastcgi_script_name;
}',
],
Fix puppet-lint

…e1.domainname.org name2.domainname.org': }

Add example nginx::vhost with HTTPS FastCGI and redirection of HTTP
Add location_custom_cfg_prepend & location_custom_cfg_append. Used for logical structures such as if.
Fix puppet-lint
@jfryman
Copy link
Contributor

jfryman commented Jan 13, 2014

Nice!

Can I trouble you for some tests as well?

@abraham1901
Copy link
Contributor Author

Оf course.

target => $config_file,
content => $content_real,
order => "${ssl_priority}",
order => $ssl_priority,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

concat::fragment expects a string, so this should be left as is (even though puppet-lint complains)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tnx
reverted


### Example puppet class calling nginx::vhost with HTTPS FastCGI and redirection of HTTP

```define web::nginx_ssl_with_redirect (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you preview this new section in the README? It doesn't render properly. The

```

must be on a line of its own, and it should read

```puppet

to get proper syntax highlighting.

@3flex
Copy link
Contributor

3flex commented Jan 16, 2014

I'm not convinced adding location_custom_cfg_* is a good idea. It's asking for an array, but then sorts it in the background which might mangle people's code. I think it's better to extend the existing location_cfg_* so it can accept either a hash or an array (or a string while we're at it!). If it's a hash, keep sorting it in the template as we do now to keep consistent ordering in Ruby 1.8. If it's an array, don't sort it since it will output in the insertion order. That way you can write your complete if statement in order and it won't be mangled by the template code.

Also, I'm not sure this example in the README really belongs - it's very specific to a single use case and makes too many assumptions about the environment it would work in (e.g. SSL is turned on, the certificate and key paths are hard coded, fastcgi is hard coded to listen on 127.0.0.1). I think it would be better to explain how to fit the components together to get this end result instead of just putting the code there when it's not going to work as is for the majority of people.

👍 to sanitizing the vhost name in the location though. Would be great to get rspec tests for this, I know sanitizing vhost isn't tested at all right now.

@abraham1901
Copy link
Contributor Author

@3flex, thanks for your code review and feedback.

I think it's better to extend the existing location_cfg_* so it can accept either a hash or an
array (or a string while we're at it!). If it's a hash, keep sorting it in the template as we do now
to keep consistent ordering in Ruby 1.8.

How could we extend location_cfg_* variables?

We use location_cfg_* for simple Nginx options:

But as for logical structures, we transmit the raw data from user to template without the symbol ';' etc.

Same as

location_custom_cfg_prepend => [
'if (-f $document_root$fastcgi_script_name){
set $fsn $fastcgi_script_name;
}',
],

I think templating these structures will reduce transparency.

Also, I'm not sure this example in the README really belongs - it's very specific to a single
use case and makes too many assumptions about the environment it would work in (e.g. SSL is
turned on, the certificate and key paths are hard coded, fastcgi is hard coded to listen on >127.0.0.1).

Well. My example is not ideal. However, php-fpm/nginx with FastCGI and HTTP -> HTTPS forwarding are applied ubiquitously. And it is not easy to implement that using the module.

SSL certificate must be deployed on the server and determine the class, maybe you suggest an alternative to do this?

It's just a simple example.

I think it would be better to explain how to fit the components together to get this end result >instead of just putting the code there when it's not going to work as is for the majority of >people.

It is really better, but it's not simple for all cases. When this is done, my example can be removed.

to sanitizing the vhost name in the location though. Would be great to get rspec tests for
this, I know sanitizing vhost isn't tested at all right now.

I do not have enough experience on rspec tests creating. Could you help me?

@3flex
Copy link
Contributor

3flex commented Jan 18, 2014

They're all fair points, though I still think the README example could be a bit more concise, and there must be a better way than adding more parameters - there will be four parameters for adding custom configuration to a location. I can't think of a good solution though.

I raised a PR on your branch with tests. rspec can be tricky if you're new to it, it took me a long time to write the tests for this module and understand how everything fit together.

test vhost name is sanitized
@abraham1901
Copy link
Contributor Author

@3flex, thank you!

@abraham1901
Copy link
Contributor Author

@jfryman ?

jfryman pushed a commit that referenced this pull request Jan 23, 2014
Fixed long names virtual hosts...
@jfryman jfryman merged commit d1dc560 into voxpupuli:master Jan 23, 2014
@jfryman
Copy link
Contributor

jfryman commented Jan 23, 2014

👍

@abraham1901
Copy link
Contributor Author

molte grazie!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants