Grafana via reverse proxy in IIS - iis

I have trouble exposing grafana via reverse proxy in IIS.
Grafana config is:
http_addr =
http_port = 3000
domain = stats.mydomain.com:80
enforce_domain = false
root_url = %(protocol)s://%(domain)s/grafana/
serve_from_sub_path = true
static_root_path = public
I successfully navigate to http://localhost:3000/grafana/ and browse the graphs it serves.
In iis, i registered the stats.mydomain.com website as a new website, then created a rewrite rule according to official guide:
iis rewrite rule for grafana
However, when i navigate to http://stats.mydomain.com/grafana/, i get a 404 error.
When I navigate to same website from server, the error is 404 and sub-error code is 4.
May I please know what is wrong?

I wasn't able to do this following Grafana's official guide located at https://grafana.com/docs/grafana/latest/tutorials/iis/
But I was able to do this following a guide on Microsoft, located here: https://techcommunity.microsoft.com/t5/iis-support-blog/setup-iis-with-url-rewrite-as-a-reverse-proxy-for-real-world/ba-p/846222#

Related

Azure Web App - Cannot GET (particular path)

I have been trying out the AADv2 sample from BotAuth to no avail.
The error that I keep getting after I select the button on the action card is that either a HTTP 500 internal server error, or Cannot GET /botauth/aadv2. When I check if the root web page or the messaging endpoint is working or not, I get the same error - either Cannot GET / or Cannot GET \api\messages. The root page I have been trying to get to is https://(botname).azurewebsites.net
May I know what steps I can take to resolve this issue? I have tried to Google the error, but to no avail. Please let me know if you need more information!
Since you are test the sample directly on Azure Web Apps, there should be a few of questions we should pay attention on.
1, const MICROSOFT_APP_ID = envx("MICROSOFT_APP_ID");
const MICROSOFT_APP_PASSWORD = envx("MICROSOFT_APP_PASSWORD");
we declare the environment valiable as MicrosoftAppId and MicrosoftAppPassword. Please modify this sentence as
//bot application identity
const MICROSOFT_APP_ID = envx("MicrosoftAppId");
const MICROSOFT_APP_PASSWORD = envx("MicrosoftAppPassword");
2, And you also need to check the environment variables are set correctly in Application settings of Azure Web App, which is shown at https://github.com/MicrosoftDX/botauth/tree/master/Node/examples/aadv2#3-setup-environment-variables
3, You can leverage online code editor to develop, debug, and manage your project on Azure Web Apps.
And in the output column, you can see the detailed errors throwm by the application. You can leverage these info to narrow down your issue.
Tips, after you changing the application settings, it's better to restart your Azure Web App.

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) {});

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

IIS 7 - Virtual directory redirection path?

I wrote this little web app that lists the websites running on the local IIS + virtual directories attached to the websites.
Using the following line I was able to get the HTTP Redirection URL of a virtual directory, if it was set to redirect:
_directoryEntry.Properties["HttpRedirect"].Value.toString()
Which works quite nicely in IIS 6 - but the value is empty when I try my app in an IIS 7 - and I tried switching the application pool to Classic pipeline as well - what has changed in IIS 7 here? And why?
In IIS7 <httpRedirect> element replaces the IIS 6.0 HttpRedirect metabase property.
You need to set it up like this in your web.config file:
<system.webServer>
<httpRedirect enabled="true" destination="WebSite/myDir/default.aspx" />"
</system.webServer>
If you do not want to tweak web.config, this article talks about a way to do them the IIS 6 way: Creating Http Redirects in IIS7 on Virtual Directories like IIS6
Hope this helps.
What has changed?: IIS7 has a completely new configuration system similar to .NET's hierarchical configuration system. Checkout this link for more detail here on what's changed.
How to get the HttpRedirect value: In C#, rather than using the System.DirectoryServices namespace to access the IIS configuration settings, use the new Microsoft.Web.Administration.dll.
Your code should look something like this example from IIS.net:
using System;
using System.Text;
using Microsoft.Web.Administration;
internal static class Sample
{
private static void Main()
{
using (ServerManager serverManager = new ServerManager())
{
Configuration config = serverManager.GetWebConfiguration("Default Web Site");
ConfigurationSection httpRedirectSection = config.GetSection("system.webServer/httpRedirect");
Console.WriteLine("Redirect is {0}.", httpRedirectSection["enabled"].Equals("true") ? "enabled" : "disabled");
}
}
}
You can actually do quite a lot with the new Microsoft.Web.Administration.dll. Checkout Carlos Ag's blog here for some ideas.
Two quick notes:
Microsoft.Web.Administration.dll is available if the "IIS Management Scripts and Tools" role service is installed. It should be under the inetsrv directory in systemroot.
Any code you run with the MWA dll needs to run as Administrator to access IIS configuration, so just make sure the account running the script has admin rights.
Hope this helps!

Can I move a MediaWiki site to a new virtual folder?

I had MediaWiki installed in as the default site on my server using IIS 6 and I created a virtual directory and pointed it to the Wiki folder. The page loads, but all the links are pointing to the original location that is no longer pointing to the Wiki Folder.
Info
Server Name: tech
Path to Wiki: http://tech/wiki/
Example
Links
Wrong Link - This is the current link displayed
http://tech/index.php?title=Main_Page
The link should look like this
http://tech/wiki/index.php?title=Main_Page
All of the links are not showing the /wiki
Any ideas?
Do you have this in your local settings?
$wgArticlePath = "/wiki/$1"; # Virtual path. This directory MUST be different from the one used in $wgScriptPath
$wgUsePathInfo = true; # Enable use of pretty URLs
Try setting
wgUsePathInfo = false;

Resources