Using Passport-google behind proxy - node.js

I'm using Passport-google to login users in example.com:3000. It works great. But if I put the Node.js server behind a proxy (IIS7; don't ask why, I had to), and access to my site in example.com (not in example.com:3000), I can't login with Passport-google. My RewriteRule in IIS:
Pattern (.*)
{HTTP_HOST} Matches myserver.com
{SERVER_PORT} Does not match 3000
Rewrite URL: http://127.0.0.1:3000/{R:1}
The error I got:
Cannot GET /accounts/o8/ud?
Also I have the same problem with Passport-twitter, and Passport-facebook.
I think I should set some other rule in IIS, or set some proxy settings in Passport.js, or OpenID, but haven't figured out yet. Any ideas?

The IIS proxy had a bad configuration. under Application Request Routing (ARR) / Server proxy settings Reverse rewrite host in response headers was switched on, so when passport sent a 302 with a location in header set to https://www.google.com/accounts/o8/... the IIS proxy replaced it to http://myserver.com/accounts/o8/... . which of course was an invalid link.

Related

Rewrite URL path in Azure Front Door - Error HTTP 404

I have the following FD routes as fictional examples:
mysite.azurefd.net/app1 --forwards--> "app1.azurewebsites.net"
mysite.azurefd.net/app2 --forwards--> "app2.azurewebsites.net"
However, Front Door is still sending the examples paths /app1 and /app2 and I get error HTTP 404.
Custom forwarding path is set like this:
Setting the match patterns like this solved my problem.
https://learn.microsoft.com/en-us/azure/frontdoor/front-door-url-rewrite
This along with setting the Custom forward path under URL rewrite is very important to make it work.

Rewrite application path from tomcat using IIS

I need to configure an URL rewrite that way:
Server Application Provider: Tomcat 8 with a Java Web Based Application.
WebServer: IIS 10.0
Original URL application:
http://localhost:8080/Spigen
Desired URL:
http://localhost/Spigen/bi/sams
I tried that way:
1- In IIS 10 I set up a Server Farm with
Server Address= localhost
httpPort= 8080
2- Configured a Rule to remove 8080 port from URL:
Rule 1
3- Configured a Rule of user-friendly URL:
user friendly config
I didn't have desired effect. When I access:
http://localhost/Spigen/bi/sams
I receive from browser 404 messagem:
404 message
I don't really have idea how could I get that.
The idea is to have several URL acessing the same application and the application make decisions based on it.
URL Examples:
/Spigen/bi/sams
/Spigen/bi/app
/Spigen/bi/nok
What configuration is missing?

URL Rewrite works with redirect but not rewrite

I set up an IIS server (IIS 8) and added URL Rewrite.
If I set:
Requested URL: "Matches the Pattern"
Using: "Regular Expressions"
Pattern: "(.*)"
No conditions
Action Type: "Redirect"
Redirect URL: "http://myloadbalancer_censored_name.elb.amazonaws.com/"
Redirect Type: "Temporary (307)"
This works the way I would expect.
When I type the url in my browser (something like "http://10.0.1.47") my browser's omnibar changes to the redirect URL (something like http://myloadbalancer_censored_name.elb.amazonaws.com/).
So far so good ...
But when I change the setting in URL Rewrite from redirect to rewrite, I get back:
HTTP Error 404.4 - Not Found
Requested URL
http://10.0.1.47:80/
Physical Path
C:\inetpub\wwwroot
I'm trying to set up a reverse proxy to pull web resources as if they came from a separate machine (to hide the internals of where my web app server actually lives).
EDIT:
In the IIS log I can see these 2 lines:
2016-04-06 15:59:34 10.0.1.11 GET / - 80 - 10.0.1.11 Mozilla/5.0+(Windows+NT+6.3;+WOW64;+Trident/7.0;+rv:11.0)+like+Gecko - 404 4 123 15
2016-04-06 16:01:07 10.0.1.11 GET / - 80 - 10.0.1.11 Mozilla/5.0+(Windows+NT+6.3;+WOW64;+Trident/7.0;+rv:11.0)+like+Gecko - 307 0 0 46
The first one is with rewrite. The second one is with redirect. This shows I am hitting the same IP, but it fails with rewrites for some reason.
Select the root level server in Internet Information Manager (IIS) and select Application Request Routing Cache.
Click “Server Proxy Settings …” on the right most pane.
Check “Enable Proxy”.

Nodejs redirect url to tomcat server

To solve CORS issue, I need remove my server port and use apache to redirect to my tomcat with port.
example: http get url: localhost/app1/somerequest, my apache server will redirect to localhost:8080/app1/somerequest, so how can this redirect be work when i use nodejs?
If you want to proxy the request, use node-http-proxy.
If you want to redirect the request, see this

Running Sonar behind Microsoft IIS with SSL enabled fails to redirect to https after successfull login

I have configured Sonar webserver to have all of the requests to go through Microsoft IIS server.
It was confirmed to work fine with requests via http protocol.
However, once the https was enabled, after successful login, Sonar webapp is trying to redirect to non-https url, causing it to timeout. If I then go and change the url to go to https, it shows as authenticated and continues to work as normal.
The same issue happens when you trying to logout - instead of redirecting to https page, it goes out to http.
What needs to be done to make Sonar post-login action to use the same protocol via which the login page was requested originally?
sonar.properties has:
sonar.web.host: 127.0.0.1
sonar.web.port: 9000
sonar.web.context: /sonar
IIS plugin has:
<VirtualHostGroup Name="default_host">
<VirtualHost Name="*:80"/>
<VirtualHost Name="*:9443"/>
<VirtualHost Name="*:443"/>
<VirtualHost Name="*:9000"/>
</VirtualHostGroup>
<ServerGroup Name="sonar_group">
<Server Name="sonar_server">
<Transport Hostname="127.0.0.1" Port="9000" Protocol="http"/>
</Server>
</ServerGroup>
<UriGroup Name="sonar_host_URIs">
<Uri Name="/sonar*"/>
</UriGroup>
<Route ServerGroup="sonar_group" UriGroup="sonar_host_URIs" VirtualHostGroup="default_host"/>
Thanks.
In the web UI (while logged in as an admin user), go to Settings -> General and make sure the URL listed under Server Base URL starts with "https". This can also be set in the server's sonar.properties file using sonar.core.serverBaseURL
This is a well-known issue with the Ruby stack, and requires tweaking the web-server config -- not that of Sonar. On Apache you'd have to do the following, Im sure the pointers in the ticket will also lead you to a solution for IIS:
RequestHeader set X_FORWARDED_PROTO "https"

Resources