How to create an application under a website using puppet - puppet

I am setting up a website in IIS with the below snippet
iis::manage_site {'Demo':
site_path => 'C:\inetpub\wwwroot\Demo',
port => '80',
ip_address => '*',
app_pool => 'Demo',
}
However I have few folders under "Demo" which needs to be converted to an application and not to be used as a virtual directory. Is there an equivalent of "iis::manage_virtual_application" for setting up an application.

Are you using the OpenTable IIS module? I know this is a requested feature, but I don't think that the module handles that yet. I see this pull request though: https://github.com/opentable/puppet-iis/pull/43

Related

Azure Application Gateway Redirection from empty hostname

I have created an Application Gateway that needs to fulfill the working of my previous Resource (F5).
As a listener I use a hostname: hostname.stackoverflow.com that listens on 443
As a Http Setting I am using a specific port being 4443
As a BackEnd pool I use the URL/FQDN of my dev VM.
This totally works If i create a VM in the VNET and add "hostname.stackoverflow.com" to the hosts file with the ip of the application gateway.
Now I want to get a little further and add paths to my Application Gateway.
The goal is that if I use "hostname.stackoverflow.com" I need to redirect this to "Hostname.stackoverflow.com/login.aspx?guestlogin".
As far I have tried the following.
Add the "/login.aspx?guestLogin" to the HTTPS settings like this.
When I try this inside my VM. The URL changes but the path that I added there was not added in the right way, This is what I got:
So That made me think override backend path is maybe not the right way to do this.
Wanted To create a Redirection Rule That will redirect my "hostname.stackoverflow.com" to the "hostname.stackoverflow.com/login.aspx?guestLogin" But in the settings of the Application Gateway I need to provide a source path (meaning: I can not redirect from an empty hostname to a new url I think)
I am very new to Azure and even more new to the Application Gateway. Is there something that I did wrong. Is there a better way to do this ?
The iRule that I need to get in Application Gateway is as followed.
if { [string tolower [HTTP::host]] equals "hostname.stackoverflow.com" } {
if {[HTTP::path] eq "/"} {
HTTP::redirect "login.aspx?guestLogin"
}
elseif {[string tolower [HTTP::uri]] starts_with "/login.aspx?id="} {
set tail [string range [HTTP::uri] 12 end]
HTTP::redirect "login.aspx?guestLogin&$tail"
}
pool default.pool
}

ServiceStack.Swagger.Api supportedSubmitMethods

I have a service set up that uses ServiceStack.Swagger.Api. My service has several endpoints that support OPTIONS requests. Is there a way to configure the SwaggerAPI plugin to add 'options' to the js SwaggerUi.supportedSubmitMethods list in the index.html?
The options requests shows but the 'Try It Out' button does not exists because the supportedSubmitMethods doesn't have options in it.
*Using ServiceStack 4.5.6
ServiceStack Swagger's embedded resource files are overridable using the Virtual File System so you can override Swagger UI's default index.html by taking a copy of index.html and adding it to your Host Project in the /swagger-ui/ folder, e.g:
/swagger-ui/index.html
Then modify your local copy of supportedSubmitMethods to include options, e.g:
window.swaggerUi = new SwaggerUi({
url: url,
dom_id: "swagger-ui-container",
supportedSubmitMethods:['get', 'post', 'put', 'delete', 'patch', 'options'],
...
Note in the latest v4.5.8 Release if you have a lot of OPTIONS Services you can add it to the list of default verbs for Routes that don't explicitly specify an HTTP Verbs with:
Plugins.Add(new SwaggerFeature
{
AnyRouteVerbs = { HttpMethods.Options },
});
Also if you're able to upgrade to v4.5.8 then you may want to consider switching to use the newer Open API Feature which implements v2.0 of the Open API specification which is the successor to Swagger.

IIS Virtual directory creates path issue

I am using VS 2013 and MVC5
To host the application in IIS, i have used Properties-> Web ->Servers ->Local IIS and clicked on Create Virtual directory.
So this created a VD for "MyPortal"
But now i have a path problem.
I have an api controller in my application.
When i was using VS development server it was being accessed using the url : localhost:1553/api/menuapi and the data was getting accessed correctly.
But once it is hosted to IIS, it stopped working.
When checked, it is trying to fetch the data from url i.e :
localhost/api/menuapi and it gives a 404 error.
But actually the api is fine and the data is accessible from the url :
localhost/MyPortal/api/menuapi
Why and how is this path problem created?
The below is how i am doing the api call :
1. In javascript file :
$http.get('/api/menuapi/' + menuid).success(function (data) {});
Please suggest if any alternatives.
The problem is that your javascript will only works if the application is deployed on the top level of the webserver (/), as you are using an absolute url.
If your javascript is executed at the top level of your application, you could just change your url as relative:
$http.get('api/menuapi/' + menuid).success(function (data) {});
but if your javascript in a view, a better approach would be to retrieve the proper full url with:
#Url.Content("~/api/menuapi/")
like:
$http.get('#Url.Content("~/api/menuapi/")' + menuid).success(function (data) {});

Could not retrieve information from environment production source(s) file:///

I've got a puppet class defined like this:
class etchostfile
(
$hostfile
)
file { $hostfile :
ensure => file,
source => "file:///var/www/cobbler/pub/hosts-${hostfile}.txt",
path => '/root/hosts',
}
}
Then I've got a node defined:
node 'hostname.fqdn.com'
{
class { 'etchostfile' :
hostfile => foo,
}
}
I want it to take the file /var/www/cobbler/pub/hosts-foo.txt and install it to /root/hosts. But I'm getting this error:
err: /Stage[main]/Etchostfile/File[foo]: Could not evaluate: Could not
retrieve information from environment production source(s)
file:///var/www/cobbler/pub/hosts-foo.txt
The file exists, is readable, and every directory leading to it is at least r-x.
I saw a number of reasons why this error applies to an incorrect puppet:/// source, but I'm using a file:/// source. I also tried disabling SELinux on both agent and master. No luck.
It worked correctly on my test host, so I presume it's a firewall issue. But the agent can get to the master on port 8140, and I already have a signed certificate, and it appears that I am at least getting a catalog, so I don't understand why I can't get a file too.
Looks like you are trying to source the file from your puppet master? In that case, you need to use the puppet:// resource and not the file:// resource.
Also, ensure that your fileserver setup on master is working.
https://docs.puppetlabs.com/guides/file_serving.html#file-server-configuration
[EDIT]
From the above linked doc first paragraph:
If a file resource declaration contains a puppet: URI in its source
attribute, nodes will retrieve that file from the master’s file server
Also, some more doc talking about file source attribute
https://docs.puppetlabs.com/references/latest/type.html#file-attribute-source
If you are trying to reference a local file (local to the node where the agent is running) you can remove the protocol part and just use:
file { $hostfile :
ensure => file,
source => "/var/www/cobbler/pub/hosts-${hostfile}.txt",
path => '/root/hosts',
}
If you are trying to access a file on the puppet master, you need to use the puppet:/// protocol (and not file). This will bring some additional restrictions : usually you do not configure puppet file serving to serve all files on the master (which would be a security issue) but only to serve files that are part of puppet modules.
Or you could use a template with no logic instead of the file:
file { $hostfile :
ensure => file,
content => template("my_module/hosts-${hostfile}.txt.erb"),
path => '/root/hosts',
}
It is counter intuitive, but using templates with no logic tends to have better performance that trying to use Puppet for file serving.

Swashbuckle running with katana-owin based web api doesnt work with IIS but works with IIS Express

I think I have a similar issue as this post-
Webactivator doesn't run on IIS 7
Swashbuckle running with katana-owin based web api is able to work with IIS Express.
assume all the urls below have an "http" prefix.
I can browse to something like localhost:8085/swagger Which redirects me correctly to localhost:8085/swagger/ui/index
But when published to IIS redirects to localhost/swagger/ui/index instead of localhost/myapp/swagger/ui/index and this results in a 404. Notice that even though an application name is specified while publishing somehow swashbuckle/swagger doesn't know and only uses the pathbase without the application name.
basically it just picks up the site root URL instead of the application URL that was used to call /swagger
Any solution to this problem?
I got the same issue. Solved this using the following code (c.RootUrl)
config.EnableSwagger(c =>
{
c.IncludeXmlComments(GetXmlCommentsPath());
c.SingleApiVersion("v1", "yourAPI");
c.RootUrl(req => req.RequestUri.GetLeftPart(UriPartial.Authority) + VirtualPathUtility.ToAbsolute("~/").TrimEnd('/'));
});
Reference : Relative path for UI request URL

Resources