In my jboss-web.xml
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web version="8.0" xmlns="http://www.jboss.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee http://www.jboss.org/schema/jbossas/jboss-web_8_0.xsd">
<context-root>SampleSpringBoot</context-root>
<virtual-host>SampleSpringBoot</virtual-host>
</jboss-web>
standalone.xml
<host name="default-host" alias="localhost">
<location name="/" handler="welcome-content"/>
<filter-ref name="server-header"/>
<filter-ref name="x-powered-by-header"/>
<http-invoker security-realm="ApplicationRealm"/>
</host>
<host name="SampleSpringBoot" alias="123.mydomain.com" default-web-module="SampleSpringBoot.war"/>
when i accessing "123.mydomain.com", then i can able to view the application index page.
When i accessing "http://localhost:8080/SampleSpringBoot", its not working 404 returns
I had tried with
<host name="SampleSpringBoot" alias="123.mydomain.com, SampleSpringBoot" default-web-module="SampleSpringBoot.war"/>
same 404 retuns
How can i access the url locally?
Thanks
Related
I created a dynamic web project and added a context.xml file to the META-INF folder as mentioned here. But when I deploy the war file the context file is not copying to the folder $CATALINA_BASE/conf/[enginename]/[hostname]/. My context.xml file content are following,
<?xml version='1.0' encoding='utf-8'?>
<Context>
<Environment name="test" value="10"
type="java.lang.Integer" override="false"/>
</Context>
Why this approach is not working? How can I set the context of a application dynamically?
Try updating the Host element inside your tag.
<Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm">
...
</Realm>
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true" copyXML="true">
I've blocked the http protocol(enabled https only) in wildfly 9.0 by changing below configuration
Changed connector-ref="default" to connector-ref="default-ssl"
<subsystem xmlns="urn:jboss:domain:remoting:3.0">
<endpoint worker="default"/>
<http-connector name="http-remoting-connector" connector-ref="default-ssl" security-realm="ApplicationRealm"/>
</subsystem>
Commented the http-listener
<subsystem xmlns="urn:jboss:domain:undertow:2.0">
<buffer-cache name="default"/>
<server name="default-server">
<!-- <http-listener name="default" socket-binding="http" redirect-socket="https"/> -->
<https-listener name="def.....
it worked..i am able to block the http and enabled https protocol access only. Ideally it should reject the http request. But, now problem is, whenever i am accessing the http://localhost:8080/MyWebApp/ , its rejecting the http request, but at the same time, web page is downloading a blank download file. why ???
Thanks.
You should redirect your http requests to https instead of disabling the http:
<connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http" redirect-port="443" />
Add a redirect handler in the handlers part, something along the way of:
<host name="other-host" alias="www.mysite.com, ${prop.value:default-alias}" default-web-module="something.war" disable-console-redirect="true">
<location name="/" handler="welcome-content">
<filter-ref name="redirects" predicate="!secure" />
</location>
<filter-ref name="headers"/>
</host>
</server>
...
https://myserver/'" redirect="true" />
I'm with a problem to configure the GZip in my Wildfly server used the following configuration on the server:
<subsystem xmlns="urn:jboss:domain:undertow:1.2">
<buffer-cache name="default"/>
<server name="default-server">
<http-listener name="default" socket-binding="http"/>
<host name="default-host" alias="localhost">
<location name="/" handler="welcome-content"/>
<filter-ref name="gzipFilter" predicate="path-suffix['.css'] or path-suffix['.js'] or path-suffix['.xhtml']"/>
<filter-ref name="server-header"/>
<filter-ref name="x-powered-by-header"/>
</host>
</server>
<servlet-container name="default">
<jsp-config/>
<websockets/>
</servlet-container>
<handlers>
<file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>
</handlers>
<filters>
<response-header name="server-header" header-name="Server" header-value="Wildfly 8"/>
<response-header name="x-powered-by-header" header-name="X-Powered-By" header-value="Undertow 1"/>
<gzip name="gzipFilter"/>
</filters>
</subsystem>
And became the Zip file of the request correctly, however I would like to set the minimum size for files to be zipped and what I'm hard, anyone know how to set the minimum size for the server do the zip before sends them to the customer?
Expanding on Alexander's answer I did some tests. Strangely enough the predicate to only compress files larger then 500 bytes is not min-content-size[500].
To configure it using jboss-cli.sh run this script:
/subsystem=undertow/configuration=filter/gzip=gzipFilter:add()
/subsystem=undertow/server=default-server/host=default-host/\
filter-ref=gzipFilter:add(predicate="not min-content-size[500]")
Note that the gzip filter will start to work after server reload. You can do this using cli's command :reload.
To test if the filter is enabled I used:
wget $MY_URL -S --header="accept-encoding: gzip" \
-O /dev/null 2>&1| grep Content-Encoding
There is a predicate in undertow min-content-size
so you can use predicate=min-content-size[500]
I found the available predicates here https://github.com/undertow-io/undertow/tree/master/core/src/main/java/io/undertow/predicate due to lack of documentation
It worked with the predicate:
predicate="exists['%{o,Content-Type}'] and regex[pattern='(?:application/javascript|text/css|text/html|text/xml|application/json)(;.*)?', value=%{o,Content-Type}, full-match=true]"
I have the following configuration running on Tomcat 8.0.20:
C:\tomcat
conf
server.xml
context.xml
webapps
app
app2
......
C:\external
app3
web
app4
web
app5
web
In context.xml I have <Context crossContext="true"> .... </Context>
And in server.xml:
..........
<Host name="host.com" appBase="webapps" unpackWARs="true" autoDeploy="true">
<Context
cachingAllowed="false"
docBase="C:\external\app3\web"
path=""
crossContext="true"
reloadable="true" />
<Context
cachingAllowed="false"
crossContext="true"
docBase="C:\external\app4\web"
path="/app4"
reloadable="true" />
<Context
cachingAllowed="false"
crossContext="true"
docBase="C:\external\app5\web"
path="/app5"
reloadable="true" />
</Host>
Obtaining the Context of /app, /app2 or /app5 from /app4 works as espected:
request.getServletContext().getContext("/app") is not null.
However, requesting the Context of /app3 (with context path /).
Any idea why getContext("/") is null?
As it turned out, it's a regression in tomcat after version 8.0.15
Filed a bug report here
Reverted tomcat to 8.0.15 and it's working now....
This is related to two posts -
Hosting multiple domains with WildFly (Undertow),
WildFly -> Undertow -> maping subdomain to war file not working
The workaround with creating/editing jboss-web.xml does not seem to be working.
I tried this workaround for my scenario where two virtual hosts are served exactly with the same WAR files, with no context-root configuration.
In wildfly/standalone/configuration/standalone.xml:
<host name="domain1" alias="domain1.rootdomain.com">
<location name="/" handler="welcome-content"/>
<filter-ref name="server-header"/>
<filter-ref name="x-powered-by-header"/>
</host>
<host name="domain2" alias="domain2.rootdomain.com">
<location name="/" handler="welcome-content"/>
<filter-ref name="server-header"/>
<filter-ref name="x-powered-by-header"/>
</host>
In jboss-web.xml:
<jboss-web>
<virtual-host>domain1</virtual-host>
<virtual-host>domain2</virtual-host>
</jboss-web>
During deploy/redeploy Wildfly complains that already one virtual-host tag was processed and the deployment/redeployment fails.
Is there any other solution for this problem?
I had the same problem for long time ago. My solution was to "merge" two host configurations in a single one, like:
<host name="domains1and2" alias="domain1.rootdomain.com, domain2.rootdomain.com">
<location name="/" handler="welcome-content"/>
<filter-ref name="server-header"/>
<filter-ref name="x-powered-by-header"/>
</host>
And then in jboss-web.xml:
<jboss-web>
<virtual-host>domain1and2</virtual-host>
</jboss-web>