why do I need port 8080 after localhost? - eclipse

I've just downloaded a java application called "test-app" that I obtained from http://www.coreservlets.com/Apache-Tomcat-Tutorial/tomcat-7-with-eclipse.html and I setup tomcat 7 in eclipse.
When I started the server I navigated to http://localhost/test-app and got a page could not be found error, but when I went to http://localhost:8080/test-app/ the page came up correctly.
Why is this occurring? The tutorial I'm following states that I should be able to navigate to the page without the 8080.

I believe port 8080 is the default port for tomcat installations. There should be a file called conf/server.xml which you can change it from 8080 to 80.
Look in server.xml for this line:
<Connector port="8080" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true" />
And change Connector port="8080" to Connector port="80"

Related

Thread-pool configuration in Jboss

I want to have more information on how configuring the Thread-pool in JBoss. My aim is to have a server that can treat as many queries as possible at the same time.
Considering that in JBoss EAP 7+ you don't have the server.xml anymore, so then you just need to edit your standalone.xml or domain.xml to include the max number of threads:
<!-- A HTTP/1.1 Connector on port 8080 -->
<Connector protocol="HTTP/1.1" port="8080" address="${jboss.bind.address}" connectionTimeout="20000" redirectPort="8443" maxThreads="300" />
I'm talking here about Undertow threads, which are shared with EJB.
There is also the IO threads that are using to connect with DB for example.

Jboss ServiceBindingManager and server.xml: ports and certificate

Using the ServiceBindingManager referencing the "sample-bindings.xml" configuration in the /conf/jboss-service.xml:
<mbean code="org.jboss.services.binding.ServiceBindingManager"
name="jboss.system:service=ServiceBindingManager">
<attribute name="ServerName">myserver</attribute>
<attribute name="StoreURL">${jboss.home.url}/docs/examples/binding-manager/sample-bindings.xml</attribute>
<attribute name="StoreFactoryClassName">
org.jboss.services.binding.XMLServicesStoreFactory
</attribute>
</mbean>
1) Having enabled the ServiceBindingManager does it mean the "server.xml" ports are overwritten by the sample-bindings.xml defined ports?
<!-- A "Connector" represents an endpoint by which requests are received
and responses are returned. Documentation at :
Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
Java AJP Connector: /docs/config/ajp.html
APR (HTTP/AJP) Connector: /docs/apr.html
Define a non-SSL HTTP/1.1 Connector on port 8080
-->
<Connector port="8080" address="${jboss.bind.address}"
maxThreads="250" maxHttpHeaderSize="8192"
emptySessionPath="true" protocol="HTTP/1.1"
compression="on"
compressionMinSize="2048"
noCompressionUserAgents="gozilla, traviata"
compressableMimeType="text/html,text/xml,text/javascript,application/x-javascript,text/css,text/plain"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true" server="server1" />
<!-- Define a SSL HTTP/1.1 Connector on port 8443
This connector uses the JSSE configuration, when using APR, the
connector should be using the OpenSSL style configuration
described in the APR documentation -->
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="250" scheme="https" secure="true"
maxHttpHeaderSize="8192"
emptySessionPath="true"
address="${jboss.bind.address}"
keystoreFile="${jboss.server.home.dir}/conf/server.keystore"
keystorePass="xx"
truststoreFile="${jboss.server.home.dir}/conf/server.keystore"
truststorePass="xx"
clientAuth="false" sslProtocol="TLS" server="server1" />
2) If the server.xml ports are not relevant any more, how can the TLS server certificate still be used?
After some googling, it does look like sample-bindings.xml ports will override server.xml ports related settings and is mainly used for running multiple instances of JBoss on the same server/machine. On the SSL scertificate, if the keystores appear to be no longer found - you can add them as program arguments either in the JAVA_OPTS section of run.conf (I'm assuming you're using an older version of JBoss) or you can add them to the command line or script you use to start JBoss, for example:
/home/jboss/jboss-eap-5.1/jboss-as/bin/./run.sh -Djavax.net.ssl.keyStore=server.keystore -Djavax.net.ssl.trustStore=server.keystore -Djavax.net.ssl.trustStorePassword=xx -Djavax.net.ssl.keyStorePassword=xx > /dev/null 2>&1 &
Note, you'd need the correct paths to the files.
We use the same keystore/truststore program arguments at work on many Jboss instances.

Port re-direction from 80 to 443 in jboss 5.1 windows

I am using Jboss 5.1 in windows 64 bit. I have also deployed an application in the server.
The application is accessible via https using the port 443.I am not using any front-end web server.
I want the URL http://example.com/context_root to get re-directed to https://example.com/contextroot. It means the re-direction is from the default http port 80 to default https port 443.
When I hit the URL with the application's context root, I am getting the following error:
The page can't be displayed.
I have made the changes in server.xml file too for port re-direction:
<!-- A HTTP/1.1 Connector on port 8080 -->
<Connector protocol="HTTP/1.1" port="80" address="${jboss.bind.address}"
connectionTimeout="20000" redirectPort="443" />
Can someone suggest me an optimal solution please?
For the redirect to https you need add in web.xml of the application the following lines:
<security-constraint>
<web-resource-collection>
<web-resource-name>Restricted application</web-resource-name>
<url-pattern>/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
See: Specifying a Secure Connection
The documentation The HTTP Connector say:
redirect-port
If this Connector is supporting non-SSL requests, and a request is
received for which a matching <security-constraint> requires SSL
transport, Catalina will automatically redirect the request to the
port number specified here.
I analysed and found a way to redirect the requests from 80 to 443.
In the bindings.xml file (C:\Jboss\jboss-5.0.1.GA\server\default\conf\bootstrap) of the windows server, change the port from 8080 to 80 as this file will have a reference to server.xml file.
<bean class="org.jboss.services.binding.ServiceBindingMetadata">
<property name="serviceName">jboss.web:service=WebServer</property>
<property name="port">80</property>
After making the above change , I restarted the server once and hit the URL using the default port. It got redirected to https(443).
This helps in forcing all the non-ssl requests to be redirected in a secure way.

How do I Configure two https connector port in jboss 7?

I need to configure 2 https ports (5480 and 8443) in jboss 7 ( I did this jboss 5 adding one more connector port). I tried creating two https connector ports in standalone-full.xml but it did not work.
Following is my current configuration for 8443 https port and I need another port 5480 as well.
<subsystem xmlns="urn:jboss:domain:web:1.2" default-virtual-server="default-host" native="false">
<connector name="https" protocol="HTTP/1.1" scheme="https" socket-binding="https" secure="true">
<ssl key-alias="tomcat" password="FOO#Bar-1" certificate-key-file="${jboss.server.config.dir}/keystore" cipher-suite="TLS_DHE_RSA_WITH_AES_256_CBC_SHA,TLS_DHE_RSA_WITH_AES_128_CBC_SHA,SSL_RSA_WITH_RC4_128_MD5" protocol="TLS" verify-client="false"/>
</ connector >
</subsystem>
<socket-binding name="https" port="8443"/>
Unless you changed some configuration, your standalone jboss container reads configuration from standalone.xml rather than from standalone-full.xml. The "full" version is like an example file.

Setting up multiple ports on a single JBoss instance?

Problem Context
Here's the situation. We are running a simulator servlet from a war. The servlet we are simulating has many instances on a single machine differentiated by port number. We would like to only deploy a single war which can be accessed by many ports.
What We Have So Far
Using a java Filter (see below for web.xml) we are able to forward to each servlet implementation based on port number (ports were added by adding extra connectors to deploy/jbossweb.sar/server.xml). This works for all web service calls, but not for wsdl requests like http://localhost:8092/simulator/sim?wsdl where 8092 is the desired version of the simulator out of many (8091, 8092, 8093, 8094). On that request the wsdl is returned correctly (each simulator implementation is slightly different) except that the URL soap:address tag always uses port 8091.
Note: We are using JBoss 5.0
relevant parts of web.xml:
<filter>
<filter-name>SimFilter</filter-name>
<filter-class>com.example.filter.MyFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>SimFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>INCLUDE</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
You need to modify Tomcat's configuration (JBoss uses an embedded version of Tomcat).
Relevant file is:
$ $JBOSS_HOME/server/default/deploy/jbossweb-tomcat55.sar/server.xml
There is a portion where you configure the binding ports. This is what comes by default:
<!-- A HTTP/1.1 Connector on port 8080 -->
<Connector port="8080" address="${jboss.bind.address}"
maxThreads="250" strategy="ms" maxHttpHeaderSize="8192"
emptySessionPath="true"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true"/>
You can add several "connectors". One for each port you need.
Then restart your JBoss.
You will see something like this on the LOG:
16:29:13,803 INFO [Http11BaseProtocol] Initializing Coyote HTTP/1.1 on http-0.0.0.0-8080
16:29:13,804 INFO [Http11BaseProtocol] Initializing Coyote HTTP/1.1 on http-0.0.0.0-8091
16:29:13,805 INFO [Http11BaseProtocol] Initializing Coyote HTTP/1.1 on http-0.0.0.0-8092
16:29:13,805 INFO [Http11BaseProtocol] Initializing Coyote HTTP/1.1 on http-0.0.0.0-8093
16:29:13,805 INFO [Http11BaseProtocol] Initializing Coyote HTTP/1.1 on http-0.0.0.0-8094
This is what you need to add on your server.xml file:
<Connector port="8091" address="${jboss.bind.address}"
maxThreads="250" strategy="ms" maxHttpHeaderSize="8192"
emptySessionPath="true"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true"/>
<Connector port="8092" address="${jboss.bind.address}"
maxThreads="250" strategy="ms" maxHttpHeaderSize="8192"
emptySessionPath="true"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true"/>
....
One XML tag for each new port.
One doubt, since all the connections are redirected to 8443, what is the point in giving multiple configuration? will it avoid port congestion?