I've got webserver template in CloudFormation. I want to use the same template for http and https.
Idea is that I'll use condition like:
Codition:
Https:
Fn::Equals: [Ref: 05HttpsUsed, Used]
and later I've got section files:
files:
full_path_apache/my_no_ssl.conf:
content: !Sub |
<proper_apache_config>
No SSL config... not important now
</proper_apache_config>
full_path_apache/my_ssl.conf:
content: !Sub |
<proper_apache_config>
SSL config... not important now
</proper_apache_config>
I'm trying to combine this. So depends if I choose to use or not https it will create a correct apache config file.
All this is inside Instace, Metadata, AWS::CloudFormation::Init: and configSets:
Edit:
I've tried also applied solution I used for Security Group:
!If [Https,
{CidrIp: 0.0.0.0/0,
IpProtocol: tcp,
FromPort: '443',
ToPort: '443'}, !Ref "AWS::NoValue"]
But still can't figure it out... Either rollback (timeout) or syntax...
You basically need Fn::If. Something like:
files:
full_path_apache/my.conf:
content: !If
- Https
- !Sub |
<proper_apache_config>
SSL config... not important now
</proper_apache_config>
- !Sub: |
<proper_apache_config>
No SSL config... not important now
</proper_apache_config>
I also think that it might be easier to create two AWS::CloudFormation::Init resources (one for HTTPS, one for non-HTTPS) instead.
Related
Issue:
I would need to change the basic /camel url which camel uses by default, but when i try to change it in application.yml nothing happens to it.
Would like to keep other systems intact without changing their urls, from what they already have (would require quiet a bit of work in back-end systems)
Current URL: http://localhost:8080/camel/hello
Desired URL: http://localhost:8080/service/hello
Checked links which are NOT working for me:
Link1
Link2
Link3
EG: application.yml
camel:
springboot:
name: CamelRestContext
component:
servlet:
mapping:
enabled: true
context-path: /service
So apparently this way works:
camel:
springboot:
name: RestDSLContext
servlet:
mapping:
context-path: /service/*
rest:
context-path: /service
I have config variable(in application.yml) as:
xyz:
exception.emails: ['abc#gmail.com']
While fetching this in local works fine but after deploying war I am getting config variable as:
xyz: [
exception: [
emails[
0
]: abc#gmail.com
]
]
I am pulling this as:
def email = Holders.config.grails.xyz.exception.emails
I'm actually surprised this work at all, because I don't think that is proper yml syntax looking at the default application.yml they specify a list of userAgents like this:
grails:
mime:
disable:
accept:
header:
userAgents:
- Gecko
- WebKit
- Presto
- Trident
Personally I like to use an application.groovy and use groovy syntax like this:
grails {
mime {
disable {
accept {
header {
userAgents:
['Gecko', 'WebKit', 'Presto', 'Trident']
}
}
}
It maybe a little out of date but here is an example of a application.yml converted to application.groovy:
https://github.com/virtualdogbert/Grails3Tutorial/blob/step_01_settings_yml_to_groovy/grails-app/conf/application.groovy
Also note in the past you could run code from application.groovy, however if you have any imports they won't work,because application.yml/groovy, is meant for the cli(pre runtime), so as a workaround you can also specify a runtime.groovy, where you can have imports. If you ever go the extra mile and write a plugin, you can specify a plugin.groovy, to set defaults.
i would like to use external parameters to config my parameters.yml.
so i follow this tutorial :
http://symfony.com/doc/current/cookbook/configuration/external_parameters.html
in my parameters.yml i have put this :
parameters:
database_host: localhost
database_port: null
database_name: '%database.name%'
database_user: '%database.user%'
database_password: '%database.pass%'
mailer_transport: smtp
mailer_host: localhost
mailer_user: null
mailer_password: null
secret: ThisTokenIsNotSoSecretChangeIt
it works when i run my website with this parameters except when i clear the cache with command line.
i got this error :
[Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException]
You have requested a non-existent parameter "database.name". Did you mean this: "database_name"?
Do you know the solution to resolve this problem.
thank you for your help
First create a php file and the logica, then import the php file to the config.yml and after comment the variables in parameters file. Have you tried to do something like this?
# parameters.php
$container->setParameter('database_name', $databaseName);
# app/config/config.yml
imports:
- { resource: parameters.php }
# app/config/parameters.yml
#database_name: '%database.name%'
#database_user: '%database.user%'
I try to understand the different between:
The class ChatsRequestHandler generate a template with the name chats.html
template = self.generate('chats.html', template_values)
In the application view its is named getchats:
application = webapp.WSGIApplication(
[('/', MainRequestHandler),
('/getchats', ChatsRequestHandler)],
The same occurs to me at edit_user.html v.s ('/edituser', EditUserProfileHandler)
How is it that the application knows that the getchats is connected to the chats.html aldo they have not the same name? I would expect that it should be the same name chats.html and ('/chats', ChatsRequestHandler).
The flow of your request goes something like this.
App Engine looks up your app.yaml file. It should contain an entry that says /getchats should be handled by application in somefile.py.
It then goes to this "application view" and matches it to a Webapp Route. In this case, that route is ('/getchats', ChatsRequestHandler).
Then it calls get or post on ChatRequestHandler, passing it the request and response objects.
The output of that is sent back to the user's browser.
You are free to implement ChatRequestHandler as you'd like. In this case you're doing so by reading in a template named chats.html, populating it with some values, and then outputting it.
So the application knows that getchats is connected to ChatRequestHandler. The name of chats.html is pretty arbitrary - the ChatReqeustHandler has to know it, but that is all. You could rename it.
Thanks for helping me:
The example a came up with comes from codenvy.com as a examples app.
1 App Engine looks up your app.yaml file. It should contain an entry that says /getchats should be handled by application in somefile.py.
Here is the app.yaml file of this application
application: 3kus-apps
version: 1
runtime: python
api_version: 1
handlers:
- url: /css
static_dir: css
- url: /js
static_dir: js
- url: /.*
script: devchat.py
So as you can see it contain's no entry that says /getchats should be handled by application in somefile.py.
What i found there is a util.js file witch has a function updateChat(). function updateChat() {downloadUrl(getRandomUrl("/getchats"), "GET", null, onChatsReturned);}.
However, I would like to know - under (1) how this should be handled by a somefile.py.
I use nginx on Debian. So besides the main configuration file /etc/nginx/nginx.conf there are folders /etc/nginx/sites-available/ with the vhost config files and /etc/nginx/sites-enabled/ with the links to active vhosts.
So let me ask my question first. Because the explanation is long and maybe you don't need to read it...
I want to be able to use several vhost templates like this:
server {
listen 80;
server_name ~^(?<project>.+)\.(?<area>.+)\.loc$;
if ($host ~ ^(?<project>.+)\.(?<area>.+)\.loc$) {
set $folder "$area/$project";
}
...
access_log /var/log/nginx/$area/$project.access.log;
error_log /var/log/nginx/error.log;
...
root /var/www/$folder/;
...
}
and to define which vhost is based on which template. Furthermore it would be great to have a possibility to "extend" the template, so that I can add new settings to my vhosts and redefine the settings inherited from the template.
How can I achieve it?
My current vhost file structure looks like this:
/etc/nginx/sites-available contains following files:
default (default vhost) ax-common-vhost (vhost template)
test.sandbox.loc (vhost based on the template ax-common-vhost; it
includes thatwith the include rule) ...and some further ones...
/etc/nginx/sites-available contains following files:
default -> /etc/nginx/sites-available/default test.sandbox.loc ->
/etc/nginx/sites-available/test.sandbox.loc ...and some further
ones...
The template ax-common-vhost defines some options like root folder dynamically, using the server name:
server {
listen 80;
server_name ~^(?<project>.+)\.(?<area>.+)\.loc$;
if ($host ~ ^(?<project>.+)\.(?<area>.+)\.loc$) {
set $folder "$area/$project";
}
...
access_log /var/log/nginx/$area/$project.access.log;
error_log /var/log/nginx/error.log;
...
root /var/www/$folder/;
...
}
So when I want to create a new vhost, I just create a new vhost file and a link to it -- and don't need to copy&paste the settings and to set the paths manually. I just need to follow the convention, that a host %project%.%area%.loc hast to be placed in [my webroot]/%area%/%project%
I thought, it works over the include rule: The server gets a request x.y.loc, looks for a file named so, openes the file, and finally processes the directives in it (so the include directive and the the whole content of the included template).
But it's not so. Nginx seems just to scan the whole folder /etc/nginx/sites-available/ (alphabetically?) and to hold on the first file / server directive the host name in the request equals/maches to.
That means, the include
include /etc/nginx/sites-available/ax-common-vhost;
is not used. Actually, I've removed the include directives from the vhost files -- and nothing has changed!
And it's a problem. Because when I add a new template, e.g. for my Zend Framework projects (with [project root]/public/ as root):
file ax-zf-vhost
server {
listen 80;
server_name ~^(?<project>.+)\.(?<area>.+)\.loc$;
if ($host ~ ^(?<project>.+)\.(?<area>.+)\.loc$) {
set $folder "$area/$project";
}
...
access_log /var/log/nginx/$area/$project.access.log;
error_log /var/log/nginx/error.log;
...
root /var/www/$folder/public/;
...
}
..., it is ignored, since the server doesn't get any information about, that the vhost myzf.sandbox.loc is based on ax-zf-vhost. Instead of this it just loops the /etc/nginx/sites-available/ folder, finds ax-common-vhost, myzf.sandbox.loc maches to the pattern ^(?.+).(?.+).loc$, and nginx uses ax-common-vhost for myzf.sandbox.loc.
How can this problem be solved?
Thanks
OK, it workz now!
I've changed the server_name block of my basic vhost file, so it porecces only the request with the hostnames listed in the directive:
file ax-common-vhost:
server {
listen 80;
server_name test.sandbox.loc foo.sandbox.loc bar.sandbox.loc;
...
}
instead of the generic server_name ~^(?<project>.+)\.(?<area>.+)\.loc$;.
The vhost files test.sandbox.loc, foo.sandbox.loc, bar.sandbox.loc etc. in /etc/nginx/sites-available/ and the links to them in /etc/nginx/sites-enabled/ are not needed anymore. I've created a link /etc/nginx/sites-enabled/ax-common-vhost to /etc/nginx/sites-available/ax-common-vhost instead.
The approach for the second common vhost file is the same and it works.
The first problem is resolved: The settings can be shared by several vhosts / server blocks and I can easily add new vhosts without duplicating the settings.
But: The vhost file with the settings cannot be extended by another file. Is it possible to do this, so that a file B can "extend" a file A, inherit its settings and overwrite only directives/rules? How can I realize that?