I'm currently trying to use an URL rewrite for content I delivered via a file handler from local file system. There doesn't seems to be a documentation and/or functionality for this. I guess I would work fine using a war file (as answered in this forum https://developer.jboss.org/message/915980) but unluckily this does not work for my stuff.
My configuration looks like this
<server name="default-server">
<http-listener name="default" socket-binding="http" max-post-size="51200000" max-parameters="10000"/>
<https-listener name="https" socket-binding="https" max-post-size="51200000" max-parameters="10000" security-realm="UndertowRealm"/>
<host name="default-host" alias="localhost">
<location name="/" handler="welcome-content"/>
<access-log rotate="true"/>
<filter-ref name="server-header"/>
<filter-ref name="x-powered-by-header"/>
<filter-ref name="connection"/>
</host>
</server>
<servlet-container name="default">
<jsp-config/>
</servlet-container>
<handlers>
<file name="welcome-content" path="C:/path/to/private/docroot"/>
</handlers>
I tried to rebuild my docroot, that it looks like an exposed .war file, so I could add a WEB-INF/undertow-handler.conf file, containing the simply following rule:
regex['/Deploy/stuff/laptop/windows/(.*)/update.xml'] -> rewrite['/Deploy/stuff/laptop/windows/new-update.xml']
but this file and/or rule seems to be plainly ignored.
Any help is greatly appreciated.
It should be undertow-handlers.conf, with an s.
Related
We're using Wildfly-17.0.1
and we have 2 spring-boot microservices which are being deployed as war on wildfly
service-a.war
service-b.war
We have jboss-web.xml in both services under src/main/webapp/WEB-INF
service-a.war
<jboss-web>
<context-root>/</context-root>
<virtual-host>default-host</virtual-host>
</jboss-web>
service-b.war
<jboss-web>
<context-root>/</context-root>
<virtual-host>b-host</virtual-host>
</jboss-web>
standalone.xml
<subsystem xmlns="urn:jboss:domain:undertow:9.0" default-server="default-server" default-virtual-host="default-host" default-servlet-container="default" default-security-domain="other" statistics-enabled="${wildfly.undertow.statistics-enabled:${wildfly.statistics-enabled:false}}">
<buffer-cache name="default" />
<server name="default-server">
<http-listener name="default" socket-binding="http" redirect-socket="https" enable-http2="true" />
<https-listener name="https" socket-binding="https" security-realm="UndertowRealm" enable-http2="true" />
<host name="default-host" alias="alias" default-web-module="service-a.war" />
<host name="b-host" alias="alias" default-web-module="service-b.war" />
</server>
...
</subsystem>
Above alias is the machine name
In the server.log we see below message when both applications are deployed
...
Registered web context: '/' for server 'default-server'
...
Registered web context: '/' for server 'default-server'
But when we try to access both services only one of the service seems to be working, other gives
<html><head><title>Error</title></head><body>404 - Not Found</body></html>
We tried giving different context-root, and we saw this in log
...
Registered web context: '/a' for server 'default-server'
...
Registered web context: '/b' for server 'default-server'
but still only one works and other gives 404.
It works when we give different alias for both the hosts
Why giving the same alias for different hosts doesn't work?
I think the string you put as virtualhost in jboss-web.xml must match the alias (not the name) in standalone conf
Instead of
<host name="b-host" alias="alias" default-web-module="service-b.war" />
Try with:
<host name="vhost2" alias="b-host" default-web-module="service-b.war" />
I recently put a basic site out on GoDaddy, and for obvious reasons, I don't want it caching the HTML files. JSON files and other resources are fine, but not the initial HTML files themselves.
This site was hand-coded in Notepad++; WordPress was not used.
On my local IIS server, the caching for HTML files was disabled without much trouble. This is the web.config file for the overall site:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<defaultDocument>
<files>
<remove value="iisstart.htm" />
<remove value="index.htm" />
<remove value="Default.asp" />
<remove value="Default.htm" />
</files>
</defaultDocument>
<caching>
<profiles>
<add extension=".html" policy="DisableCache" kernelCachePolicy="DisableCache" />
</profiles>
</caching>
</system.webServer>
</configuration>
The addelement under caching/profiles works just fine on my IIS server when testing locally. However it's been noticed that it is effectively getting ignored on GoDaddy / Plesk.
So my question is: What do you have to do to get GoDaddy / Plesk to go ahead and stop caching the HTML files?
Try to add below code in your web.config file:
<caching>
<add extension=".html" policy="DontCache" kernelCachePolicy="DontCache" />
</caching>
when you try to access site hard refresh the browser and check that is it working or not.
You could refer this link for more detail.
I use undertow to serve some app logs, but I can't figure out how to sort files, for example for modification time... is there a way?
This is the subsystem conf:
<subsystem xmlns="urn:jboss:domain:undertow:3.0">
...
<server name="default-server">
...
<host name="default-host" alias="localhost">
...
<location name="/logs" handler="logs"/>
...
</host>
...
</server>
...
<handlers>
...
<file name="logs" path="/home/app/logs" directory-listing="true"/>
</handlers>
...
</subsystem>
I'm trying to redirect my URL with the following settings in the standalone.xml:
<server name="default-server">
<http-listener name="default" socket-binding="http" redirect-socket="https" enable-http2="true"/>
<https-listener name="https" socket-binding="https" security-realm="ApplicationRealm" enable-http2="true"/>
<host name="default-host" alias="localhost">
<location name="/en/" handler="en"/>
<location name="/de/" handler="de"/>
<location name="/" handler="de"/>
<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="en" path="${jboss.home.dir}/standalone/deployments/en"/>
<file name="de" path="${jboss.home.dir}/standalone/deployments/de"/>
</handlers>
My handlers point on to the matching angular frontend-projects in the deployments folder of my wildfly-server, where also my EAR-file is deployed.
This works fine except for one case: If i refresh my detail-page, which looks like this: localhost:8080/en/details/1234 i get an error
404 - Page not found
I already tried <location name="/en/details/1234" handler="en"/> which works, but obviously only for that specific id.
In my understanding this could be solved by adding something like
<location name="/en/details/(.*)" handler="en"/>
My problem is that I can't figure out how to put a placeholder like a regular expression after "details/". Is that even possible? Or is there a better way of handling this redirection/rewriting problem?
I already gave undertow-handlers.conf a shot, but it felt like it never really triggered the rewrite rules I implemented there.
We are trying to integrate a 'build once, deploy anywhere' model in our build-deploy system.
MSDeploy works wonders for this, cutting down build time dramatically with CRC checksum comparisons and (for the most part) it works just as well when using parameterisation to change applications web.configs depending on the environment we deploy to.
I have the majority of these parameters nailed down, but a few elements and attributes never seem to change, no matter how many different ways I call them in the parameters.xml file. I have outlined three examples of this, here is the web.config file I am trying to change:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<add name="DbConnectionString" connectionString="Data Source=null;Initial Catalog=null;Trusted_Connection=no;User ID=user1;Password=pass*9;" providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<customErrors mode="On" defaultRedirect="/Library/Error/PageNotFound.aspx">
</customErrors>
</system.web>
<applicationSettings>
<settings>
<setting name="service_Address" serializeAs="String">
<value></value>
</setting>
<settings>
</applicationSettings>
</configuration>
Here is the parameters.xml file:
<parameter name="DbConnectionString" defaultValue="">
<parameterEntry kind="XmlFile" scope="\\web.config$" match="/configuration/connectionStrings/add[#name='DbConnectionString']/#connectionString" />
</parameter>
<parameter name="customErrorsMode" defaultValue="">
<parameterEntry kind="XmlFile" scope="\\web.config$" match="configuration/system.web/customErrors/#mode" />
</parameter>
<parameter name="service_Address" defaultValue="">
<parameterEntry kind="XmlFile" scope="\\web.config$" match="/configuration/applicationSettings/aim.Web.Properties.Settings/setting[#name='service_Address']/value" />
</parameter>
And here is the corresponding setParameters.xml file:
<setParameter name="DbConnectionString" value="Data Source=dbserver;Initial Catalog=DB1;Trusted_Connection=no;User ID=user1;Password=pass*9;"/>
<setParameter name="customErrorsMode" value="Off"/>
<setParameter name="service_Address" value="https://myservice.asmx"/>
I have tested each XPath expression and the results are the exact same as any of the other working parameters, but the above never seem to change.
Does anyone see anything obvious I'm missing here?
service_Address
I found the answer to this problem here:
Replace web.config elements with MSDeploy
I was missing 'text()' at the end of the XPath expression, the correct XPath is:
/configuration/applicationSettings/aim.Web.Properties.Settings/setting[#name='aim_Web_AddressService_Address']/value/text()
customErrorsMode
For the customErrorsMode problem, I was missing a '/' at the start of my XPath expression. The correct expression is:
/configuration/system.web/customErrors/#mode
connectionStrings
This one really got to me, it was the last one I figured out. After doing a bit of digging I found out that MSDeploy automatically parameterizes certain elements, connection string being one of them, more info here:
Configuring Parameters for Web Package Deployment
My parameter declaration for the connection string in question should have been:
<parameter name="DbConnectionString-Web.config Connection String" defaultValue="">
<parameterEntry kind="XmlFile" scope="\\web.config$" match="/configuration/connectionStrings/add[#name='DbConnectionString']" />
</parameter>
My setParameter definition should have looked like this:
<setParameter name="DbConnectionString-Web.config Connection String" value="Data Source=dbserver;Initial Catalog=DB1;Trusted_Connection=no;User ID=user1;Password=pass*9;" />