how to redirect domian.com to www.domain.com in jboss 7.1.1 server - jboss7.x

In my website i get ssl for www.domain.com. i open using this its worked fine, when i use domain.com it show security exception how to resolve that
i used url rewrite in my standalone.xml file like below but it not worked for me
<virtual-server name="default-host" enable-welcome-root="false">
<alias name="domain.com"/>
<alias name="www.domain.com"/>
<rewrite pattern="^(.*)$" substitution="https://$1" flags="R=301,L">
<condition test="%{HTTP_HOST}" pattern="^www\.(.+)$" flags="NC"/>
</rewrite>
</virtual-server>
please let me know if i did anything wrong?

its worked fine after this changes
<rewrite pattern="^(.*)$" substitution="https://www.domain.com$1" flags="R=301,L">
<condition test="%{HTTP_HOST}" pattern="!^www\.domain\.com$" flags="NC"/>
</rewrite>

Related

Redirect Response always redirects to the same domain

I'm writing a suite of ASP.NET Core web applications that occasionally have to redirect to one another. When testing locally, everything works fine. However, when I publish them on our staging server, the redirects always "stay" in the same host. For example, if I am on http://app1.test/ and redirect to http://app2.test/somepath, what I actually get in the Location HTTP header i http://app1.test/somepath: any URL I specify is transformed so that it "stays" in the current host name.
This doesn't happen locally, however. I've deployed the apps as Kestrel processes, and they are exposed via IIS working as a reverse proxy. May this be the cause? What should I do to fix the issue?
UPDATE
Here is the full web.config for the reverse proxy of app1.test:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="ReverseProxyInboundRule1" stopProcessing="true">
<match url="(.*)" />
<action type="Rewrite" url="http://localhost:5000/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
<system.web>
<sessionState mode="InProc" />
<customErrors mode="RemoteOnly" />
</system.web>
</configuration>
app2.test's web.config is virtually the same (apart, of course, for the port numbers).
UPDATE 2
I'll try to explain better. I noticed that the target site doesn't really matter, so I'll keep things simpler: I have an action in my application that I want to redirect the user to Google. This is the action, in the Home controller:
public IActionResult ToGoogle()
{
return Redirect("https://www.google.com?q=Hi");
}
If I launch the web app locally and request http://localhost:1234/Home/ToGoogle, everything is fine: the response is a 302 Found, with the correct URL (www.google.com etc.) in the Location header.
Once I publish the app to the staging server (Kestrel app on port 5000, behind an IIS reverse proxy with the rewrite rule posted above), this is what happens instead:
What is the cause of that?
I found the solution myself. It was indeed a problem with reverse proxy.
IIS has an option to rewrite the host in response headers. The solution is described in this answer (there are addenda in other answers to that same question if your version of IIS or Windows Server is not the one specified).

URL should hit https instead of http

I am running a Windows Server, where i have hosted a site.
Now i have done the Binding with the SSL certificate for the site. But every time i hit the website URL, it goes to http instead of https. Althoough i have binded http & https with the SSL certificate.
Example -
when i try to hit abc.com
it goes http://example.com
instead of
https://example.com
Do i have to do anything more which can help me to fix this issue.
so everytime i try to visit
example.com
i will visit
https://example.com
Do anyone knows a way to fix this issue !
You need to add a redirect to make sure all traffic gets redirected, something like below. Make sure you have the URL rewrite module installed.
<rule name="HTTPS force" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
</rule>

Trying to access UpSource over https via IIS Reverse Proxy returns an empty page

I am currently trying to set up various Jetbrains services for use via https by using an IIS reverse proxy. The complete intended setup should looks somewhat like this:
TeamCity: https://server.company.com -> http://server.company.com
YouTrack: https://server.company.com/youtrack/ -> http://server.company.com:1234/issues/
Hub: https://server.company.com/hub/ -> http://server.company.com:5678/hub/
UpSource: https://server.company.com/upsource/ -> http://server.company.com:9876
I have already gotten this to work, with some difficulty, for TeamCity and YouTrack by using the following configuration:
In IIS, I have a TeamCity website that serves as a redirect. The web.config of that site currently looks as follows:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear />
<rule name="Reverse Proxy to TeamCity" stopProcessing="true">
<match url="^teamcity/(.*)" />
<action type="Rewrite" url="http://server.company.com/{R:1}" />
</rule>
<rule name="Reverse Proxy to YouTrack" stopProcessing="true">
<match url="^youtrack/(.*)" />
<action type="Rewrite" url="http://server.company.com:8080/issues/{R:1}" />
</rule>
<rule name="Reverse Proxy to Hub" stopProcessing="true">
<match url="^hub/(.*)" />
<action type="Rewrite" url="http://server.company.com:8082/hub/{R:1}" />
</rule>
<rule name="Reverse Proxy to UpSource" stopProcessing="true">
<match url="^upsource/(.*)" />
<action type="Rewrite" url="http://server.company.com:8081/{R:1}" />
</rule>
<rule name="Reverse Proxy to Collaboration General" stopProcessing="true">
<match url="(.*)" />
<action type="Rewrite" url="http://server.company.com/{R:1}" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
In addition, I have configured the following server variables as described in the documentation:
HTTP_X_FORWARDED_HOST
HTTP_X_FORWARDED_SCHEME
HTTP_X_FORWARDED_PROTO
However, when trying to access UpSource via https://server.company.com/upsource/, all I get is an empty page titled "Upsource". No error message. Not even a Fav Icon. Accessing UpSource via http://server.company.com:8081/ still works as normal though.
I have also already tried running the following chain of commands:
upsource.bat stop
upsource.bat configure --listen-port 8081 --base-url https://server.company.com:443/upsource/
upsource.bat start --J-Dbundle.websocket.compression.enabled=false
However, that did just caused the problem to change to:
HTTP ERROR: 404
Problem accessing /bundle/starting. Reason:
Not Found
Powered by Jetty:// 9.3.20.v20170531
How can I set up UpSource to work like TeamCity and Hub are already doing?
Any help on this would be greatly appreciated.
With some help of a YouTrack support employee helping with a related YouTrack error, I was able to figure out the reason behind this issue.
The reason is this: When accessing UpSource via https using a path for the redirect, the path needs to be the same in both the http and https variants.
In short, this will not work:
https://server.company.com/upsource -> http://server.company.com:9876
But this will:
https://server.company.com/upsource -> http://server.company.com:9876/upsource
I got this to work by running the following configurational command on the upsource.bat in [InstDir]/bin:
upsource.bat configure --listen-port 9876 --base-url http://server.company.com:9876/upsource
Now I can at the very least connect to and log in to UpSource via https. There's still a problem, but since it's unrelated to the topic of this question, I will create a separate question for it.
Note: on IIS 8.5 set HTTP1.1 at ARR PROXY-Settings. Otherwise the websocket connects, but there's no communication.
upsource v. upsource-2018.2.1291
https://www.jetbrains.com/help/upsource/proxy-configuration.html#IISreverseProxy

Apache Tomcat virtual directories. Redirects to wrong location. ColdFusion Lucee

I am trying to get a local version of Lucee ColdFusion running my app - which resides as two directories... the main app, and the client custom code.
To that myDomain.com should pull from the 'site' and myDomain.com/app/ should pull from the app.
I can be logged in to my site, and pulling data via includes etc, but if I try to browse (or make a call to) /app/cfc/myCFC.cfc ...
the behavior redirects to the 'root' and logs my app out.
my server XML looks like this
<?xml version='1.0' encoding='utf-8'?>
<Server port="8005" shutdown="SHUTDOWN" >
<Listener className="org.apache.catalina.startup.VersionLoggerListener" />
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
<Service name="Catalina" >
<Connector port="8888"
protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Connector port="8009"
protocol="AJP/1.3"
redirectPort="8443" />
<Engine name="Catalina"
defaultHost="127.0.0.1" >
<Host name="local.dev.myDomain.com" appBase="webapps" >
<Context path="/" docBase="C:\wwwroot\site" />
<Context path="/app" docBase="C:\wwwroot\app" />
</Host>
</Engine>
</Service>
</Server>
If it helps to understand; this is a legacy app running in production on Windows, Apache 2.2 and ColdFusion 11. I have the app aliased in Apache 2.2 like this:
Alias /app/ C:/wwwroot/app
I am trying to evaluate Lucee to see if our app will work on that platform without too many changes.
One noticeable difference, due to using the built in webserver, is the port 8888
so the actual url looks like: mydomain.com:8888/app/cfc
I do not know if this is the problem or something else. If I cannot find a solution, I'll install Apache 2.2 and match the config
Any help is greatly appreciated - jp
NOTE: I just changed the host in this txt to accurately mimic my setup - if that makes a difference.
local.dev.myDomain.com (only the 'myDomain' is specifically my domain, not literally myDomain)

How to connect JBoss AS 7.1.1 with IIS 7 using Apache ISAPI Redirector 1.2.37

I am trying to migrate my web app from JBoss EAP 5 to AS 7.1.1 and I am not able to get the IIS requests redirected to JBoss Web (Tomcat) on Windows 2008 R2 X64.
I have the filter authorized and running in IIS and pointing to the proper DLL and properties files and followed all the instructions I could find to get this working under JB 7 (it worked under JB 5). I am missing the last step which no one seems to be covering in their posts and answers.
Where do you make the changes to connect JBoss Web to port 8009 used by the AJP 1.3 connector?. Most of the examples refer to updating the connector in the server.xml file in JBOSS_HOME/server/default/Deploy/jbossweb.sar.
I don’t have anything like that under the new JBOSS_HOME/standalone/deployments folder. Where is JBoss Web configured?
Thank you for any pointers or examples you could supply.
Finally figured it out, the problem was a missing ajp connector that had to be defined in standalone.xml in the web subsystem as follows:
<subsystem xmlns="urn:jboss:domain:web:1.1" default-virtual-server="eStar-Host" native="false">
<connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/>
<connector name="https" protocol="HTTP/1.1" scheme="https" socket-binding="https" secure="true">
<ssl/>
</connector>
<connector name="ajp13" protocol="AJP/1.3" scheme="http" socket-binding="ajp" redirect-port="8443"/>
<virtual-server name="eStar-Host" enable-welcome-root="true">
<alias name="localhost"/>
</virtual-server>
</subsystem>