IIS Rewire URL regular expression - wcf

I have multiple services at Internal.com/Services . As the name suggests this is an internal page, not accessible from outside.
I have setup a site, external.com, where i will add a Reverse Proxy rule to rewrite to Internal.com/Services.
The problem I have now is that different services in Internal.com are hosted like this:
interal.com/Services/oneService.svc
internal.com/Services/anotherService.svc
This is the exact mapping i need from external.com server
external.com/oneService.svc ---> interal.com/Services/oneService.svc
external.com/anotherService.svc ---> internal.com/Services/anotherService.svc
How can i achieve this when setting the reverse proxy rule in IIS?

Burned too many hours on this, but this solved it for me. Changing the .Net framework version for the application pool for the remote proxy site to 'no managed code'.
Notice that rewriting in my case only failed when it came to .svc files. Regular html worked fine.
https://webmasters.stackexchange.com/questions/66974/iis-reverse-proxy-failing-on-svc-pages-and-some-other-pages-works-fine-for-pla

Related

Reverse proxy support in Quarkus

I have Embedded Jetty running which has reverse proxy servlet mapped for a particular URL. For ex: http://url1/abc is reverse proxied to http://url2. This works great, whenever someone calls http://url1/abc, data is served from http://url2.
I want to achieve the same using quarkus. Is this possible to do it in Quarkus? I think one of the option is to write own code in ContainerRequestFilter but I am looking more for OOTB support just like jetty. Can somehow undertow be leveraged here?
Please help.
UPDATE 1
I tried to do it through undertow-handlers.conf (placing it in META-INF folder). It worked well for redirect and rewrite but throwing error for reverse-proxy:
path-prefix('/a') -> redirect('/b)
path-prefix('/a1') -> rewrite('/b1')
path-prefix('/a2') -> reverse-proxy('http://localhost:7100/b')
If I have first two only, quarkus is started successfully and requests are served correctly. If I started using third one, quarkus start gets failed with below error.
Caused by: java.lang.RuntimeException: java.lang.IllegalArgumentException: UT000045: Error parsing predicated handler string no handler named reverse-proxy known handlers are [disallowed-methods, allowed-methods, jdbc-access-log, secure-cookie, access-log, mark-secure, response-rate-limit, canonical-path, response-code, disable-cache, ssl-headers, trace, blocking, url-decoding, access-control, redirect, set, ip-access-control, request-limit, resource, restart, clear, byte-range, done, rewrite, forwarded, stuck-thread-detector, jvm-route, learning-push, dump-request, proxy-peer-address, resolve-local-name, header, store-response, path-separator, resolve-peer-name]:
Although, I see undertow has reverse-proxy handler, not sure why it is not working for me.
http://undertow.io/undertow-docs/undertow-docs-2.0.0/index.html#predicates-attributes-and-handlers
I think the main issue is of dependency here. I see io\undertow\server\handlers package in my app libs but not io\undertow\server\handlers\proxy where I think the reverse proxy code is present.
How can I pull this dependency in my app?

HTTP Error 404.0 - Not Found when accesing SVC service

I have REST service application which is hosted in an IIS 8 in a Windows 8 PC. When I request the service I am getting an error as follows ... HTTP Error 404.0 - Not Found.
Here is the detailed error message.
HTTP Error 404.0 - Not Found
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.
Most likely causes:
•The directory or file specified does not exist on the Web server.
•The URL contains a typographical error.
•A custom filter or module, such as URLScan, restricts access to the file.
Things you can try:
•Create the content on the Web server.
•Review the browser URL.
•Create a tracing rule to track failed requests for this HTTP status code and see which module is calling SetStatus. For more information about creating a tracing rule for failed requests, click here.
Detailed Error Information:
Module IIS Web Core
Notification MapRequestHandler
Handler StaticFile
Error Code 0x80070002
Requested URL http://IP.com/Wining/RService.svc/general
Physical Path C:\inetpub\wwwroot\Wining\RService.svc\general
Logon Method Anonymous
Logon User Anonymous
Any help on this would be greatly appreciated.
There are myriads of possible causes. In general, the target resource at given URL is not found, so it may be simply missing, misconfigured, not started, etc. First - check the server logs, they usually contain more detailed information about the issue.
Also, please doublecheck that the service really is up and running. Connect to the www server and check it via localhost not ip.com.
I'm not an expert, but judging from the snippet you provided, it seems to be WCF service, the Handler: StaticFile seems very odd. It seems like the IIS misinterpretes your request as a StaticFile (a resource read from the disks and just passed-through without any further processing) which for me seems perfectly wrong.
You may have not installed the service properly, or have url mappings and/or handlers messed up, or you may even have NET/ASP framework not properly installed.. What have you installed first? .Net or IIS?
check similar questios, there are many.. for example:
WCF on IIS8; *.svc handler mapping doesn't work
HTTP 404 when accessing .svc file in IIS
I had to enable HTTP Activation in .NET Framework 4.5 Advanced Services > WCF Services (running on WIndows 2012) and after an IISReset it worked fine.

Xsp2 and multiple applications - can't get working

I try to setup xsp2 webserver to serve multiple applications.
Created the configuration file sites.webapp
<apps>
<web-application>
<name>app1</name>
<vhost>domain1.com</vhost>
<vport>8080</vport>
<vpath>/</vpath>
<path>/var/www/app1</path>
</web-application>
<web-application>
<name>app2</name>
<vhost>domain2.com</vhost>
<vport>8080</vport>
<vpath>/</vpath>
<path>/var/www/app2</path>
</web-application>
</apps>
Then I start the server
xsp2 --appconfigfile site.webapp
http://domain1.com:8080 shows a page from app2.
http://domain2.com:8080 shows the same page from app2.
Seems the xsp2 uses the last application from sites.webapp and serves all requests with it.
What am I doing wrong? Please help to setup multiple virtual hosts for xsp2.
Found an answer for my question. Support of multiple hosts is not implemented in xsp2.

WCF and IIS confusion on the wsdl location

I created my WCF project and it works fine when I just run it from the debugger.
But when I publish it to IIS and point a browser to the svc the path used has localhost in it. Like this:
htpp://localhost/MyService/MyServices.svc
but the path that the webpage says to go to for the WSDL uses my computer name, like this:
http://MyComputerName.MyDomain.net/MyService/MyService.svc?wsdl
When I click on the link it times out. (Also, trying to view the services like that in WCFTestClient times out.)
However, if I go the wsdl using localhost then it works right away:
http://lcoalhost/MyService/MyService.svc?wsdl
Any link that uses my computer name times out ("takes too long to respond").
Any idea on how to make my WCF service work with the computer name?
(NOTE: I am using Visual Studio Ultimate and IIS 7)
Try adding MyComputerName.MyDomain.net to your proxy bypass list in Internet Explorer proxy configuration setting. Check that the IIS website has this FQDN in it's hostname in the site bindings.
Also what happens if you only use MyComputerName without the domain ?

Publishing my WCF Service to my webhotel provider

I have made a small log service that i want to publish to a subdomain on my webhotel. I make the wcf service and test it locally - no problem. I then go to the [Build] menu and choose [Publish], type in my FTP location and publishes it to the location. No problems.
The problem arise when i need to use it, i try to navigate to the .svc file but gets this error:
This collection already contains an address with scheme http. There can be at most one address per scheme in this collection.
Parameter name: item
What am I doing wrong?
That's because of your IIS configuration. This has already been discussed here: WCF service startup error "This collection already contains an address with scheme http"
Solved! The problem is that i cannot access the IIS configuration, since its on a hosted environment. The solution is described on my blog, since i had so much trouble getting this to work.
http://www.vikingworks.dk/post/WCF-Service-on-hosted-environment.aspx