Binding a WebAppContext to a specific connector?

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Binding a WebAppContext to a specific connector?

Steve Sobol - Lobos Studios

Hello :)

https://stackoverflow.com/questions/26148418/jetty-9-setting-up-handlers-and-connectors talks about setting up a handler that is only used to respond to requests on a specific connector:

 

    ServerConnector httpConnector = new ServerConnector(server);

    httpConnector.setName("unsecured"); // named connector

    httpConnector.setPort(80);

 

    ContextHandler helloHandler = new ContextHandler();

    helloHandler.setContextPath("/hello");

    helloHandler.setHandler(new HelloHandler("Hello World"));

    helloHandler.setVirtualHosts(new String[]{"@unsecured"});

 

Does this work out of the box for web app contexts? Part of my code follows:

 

ServerConnector sslConnector = new ServerConnector(s,
     
new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()),
     
new HttpConnectionFactory(sslHttpConfig));
sslConnector.setName(
"https");
sslConnector.setHost("0.0.0.0");
sslConnector.setPort(
443);

 

ServerConnector nonSslConnector = new ServerConnector(s,
     
new HttpConnectionFactory(),
     
new HttpConnectionFactory(nonSslHttpConfig));
nonSslConnector.setName(
"http");
nonSslConnector.setHost(
"0.0.0.0");
nonSslConnector.setPort(
80);

 

WebAppContext t1 = new WebAppContext();
t1.setContextPath(
"/");
t1.setDisplayName(
"abc");
t1.setWar(
"c:/TempWebapp-1.0.war");
t1.setVirtualHosts(
new String[] {"@https","admin.bamidbarconnect.com","test2.local"});
WebAppContext t2 =
new WebAppContext();
t2.setContextPath(
"/");
t2.setResourceBase(
"c:/TempWebapp2/");
t2.setParentLoaderPriority(
true);
t2.setVirtualHosts(
new String[] {"@http","test1.local"});

s.setConnectors(
new Connector[]{nonSslConnector, sslConnector});

HandlerList list =
new HandlerList();
list.addHandler(t1);
list.addHandler(t2);

s.setHandler(list);

 

If it’s supposed to work, it doesn’t seem to be working for me. T1 is only supposed to be served via the SSL connector on port 443 and T2 is only supposed to be served on the non-SSL connector on port 80.

 

Thanks

--Steve

 

--

Lobos Studios | Phone: 877.919.4WEB | LobosStudios.com | Facebook.com/LobosStudios | @LobosStudios

Web Development - Mobile Development - Helpdesk/Tech Support - Computer Sales & Service

Acer Authorized Reseller - Computers, Windows and Android Tablets, Accessories

 

Steve Sobol - CEO, Senior Developer and Server Jockey

[hidden email]

 


_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: Binding a WebAppContext to a specific connector?

Joakim Erdfelt-8
virtualHosts are not AND logic, they are OR logic.

Said another way, if you have a context.virtualHosts, then the incoming request MUST match ONE of the virtualHosts entries.

- Joakim

Joakim Erdfelt / [hidden email]

On Thu, Mar 22, 2018 at 11:06 PM, Steve Sobol - Lobos Studios <[hidden email]> wrote:

Hello :)

https://stackoverflow.com/questions/26148418/jetty-9-setting-up-handlers-and-connectors talks about setting up a handler that is only used to respond to requests on a specific connector:

 

    ServerConnector httpConnector = new ServerConnector(server);

    httpConnector.setName("unsecured"); // named connector

    httpConnector.setPort(80);

 

    ContextHandler helloHandler = new ContextHandler();

    helloHandler.setContextPath("/hello");

    helloHandler.setHandler(new HelloHandler("Hello World"));

    helloHandler.setVirtualHosts(new String[]{"@unsecured"});

 

Does this work out of the box for web app contexts? Part of my code follows:

 

ServerConnector sslConnector = new ServerConnector(s,
     
new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()),
     
new HttpConnectionFactory(sslHttpConfig));
sslConnector.setName(
"https");
sslConnector.setHost("0.0.0.0");
sslConnector.setPort(
443);

 

ServerConnector nonSslConnector = new ServerConnector(s,
     
new HttpConnectionFactory(),
     
new HttpConnectionFactory(nonSslHttpConfig));
nonSslConnector.setName(
"http");
nonSslConnector.setHost(
"0.0.0.0");
nonSslConnector.setPort(
80);

 

WebAppContext t1 = new WebAppContext();
t1.setContextPath(
"/");
t1.setDisplayName(
"abc");
t1.setWar(
"c:/TempWebapp-1.0.war");
t1.setVirtualHosts(
new String[] {"@https","admin.bamidbarconnect.com","test2.local"});
WebAppContext t2 =
new WebAppContext();
t2.setContextPath(
"/");
t2.setResourceBase(
"c:/TempWebapp2/");
t2.setParentLoaderPriority(
true);
t2.setVirtualHosts(
new String[] {"@http","test1.local"});

s.setConnectors(
new Connector[]{nonSslConnector, sslConnector});

HandlerList list =
new HandlerList();
list.addHandler(t1);
list.addHandler(t2);

s.setHandler(list);

 

If it’s supposed to work, it doesn’t seem to be working for me. T1 is only supposed to be served via the SSL connector on port 443 and T2 is only supposed to be served on the non-SSL connector on port 80.

 

Thanks

--Steve

 

--

Lobos Studios | Phone: 877.919.4WEB | LobosStudios.com | Facebook.com/LobosStudios | @LobosStudios

Web Development - Mobile Development - Helpdesk/Tech Support - Computer Sales & Service

Acer Authorized Reseller - Computers, Windows and Android Tablets, Accessories

 

Steve Sobol - CEO, Senior Developer and Server Jockey

[hidden email]

 


_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users


_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: Binding a WebAppContext to a specific connector?

Steve Sobol - Lobos Studios
So if I want a WebAppContext to serve my app only for certain hostnames and only on one connector, that isn’t possible?




On Fri, Mar 23, 2018 at 2:59 AM -0700, "Joakim Erdfelt" <[hidden email]> wrote:

virtualHosts are not AND logic, they are OR logic.

Said another way, if you have a context.virtualHosts, then the incoming request MUST match ONE of the virtualHosts entries.

- Joakim

Joakim Erdfelt / [hidden email]

On Thu, Mar 22, 2018 at 11:06 PM, Steve Sobol - Lobos Studios <[hidden email]> wrote:

Hello :)

https://stackoverflow.com/questions/26148418/jetty-9-setting-up-handlers-and-connectors talks about setting up a handler that is only used to respond to requests on a specific connector:

 

    ServerConnector httpConnector = new ServerConnector(server);

    httpConnector.setName("unsecured"); // named connector

    httpConnector.setPort(80);

 

    ContextHandler helloHandler = new ContextHandler();

    helloHandler.setContextPath("/hello");

    helloHandler.setHandler(new HelloHandler("Hello World"));

    helloHandler.setVirtualHosts(new String[]{"@unsecured"});

 

Does this work out of the box for web app contexts? Part of my code follows:

 

ServerConnector sslConnector = new ServerConnector(s,
     
new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()),
     
new HttpConnectionFactory(sslHttpConfig));
sslConnector.setName(
"https");
sslConnector.setHost("0.0.0.0");
sslConnector.setPort(
443);

 

ServerConnector nonSslConnector = new ServerConnector(s,
     
new HttpConnectionFactory(),
     
new HttpConnectionFactory(nonSslHttpConfig));
nonSslConnector.setName(
"http");
nonSslConnector.setHost(
"0.0.0.0");
nonSslConnector.setPort(
80);

 

WebAppContext t1 = new WebAppContext();
t1.setContextPath(
"/");
t1.setDisplayName(
"abc");
t1.setWar(
"c:/TempWebapp-1.0.war");
t1.setVirtualHosts(
new String[] {"@https","admin.bamidbarconnect.com","test2.local"});
WebAppContext t2 =
new WebAppContext();
t2.setContextPath(
"/");
t2.setResourceBase(
"c:/TempWebapp2/");
t2.setParentLoaderPriority(
true);
t2.setVirtualHosts(
new String[] {"@http","test1.local"});

s.setConnectors(
new Connector[]{nonSslConnector, sslConnector});

HandlerList list =
new HandlerList();
list.addHandler(t1);
list.addHandler(t2);

s.setHandler(list);

 

If it’s supposed to work, it doesn’t seem to be working for me. T1 is only supposed to be served via the SSL connector on port 443 and T2 is only supposed to be served on the non-SSL connector on port 80.

 

Thanks

--Steve

 

--

Lobos Studios | Phone: 877.919.4WEB | LobosStudios.com | Facebook.com/LobosStudios | @LobosStudios

Web Development - Mobile Development - Helpdesk/Tech Support - Computer Sales & Service

Acer Authorized Reseller - Computers, Windows and Android Tablets, Accessories

 

Steve Sobol - CEO, Senior Developer and Server Jockey

[hidden email]

 


_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users


_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: Binding a WebAppContext to a specific connector?

Steve Sobol - Lobos Studios
It didn’t seem to work when I only used the connector names, either.




On Fri, Mar 23, 2018 at 7:38 AM -0700, "Steve Sobol - Lobos Studios" <[hidden email]> wrote:

So if I want a WebAppContext to serve my app only for certain hostnames and only on one connector, that isn’t possible?




On Fri, Mar 23, 2018 at 2:59 AM -0700, "Joakim Erdfelt" <[hidden email]> wrote:

virtualHosts are not AND logic, they are OR logic.

Said another way, if you have a context.virtualHosts, then the incoming request MUST match ONE of the virtualHosts entries.

- Joakim

Joakim Erdfelt / [hidden email]

On Thu, Mar 22, 2018 at 11:06 PM, Steve Sobol - Lobos Studios <[hidden email]> wrote:

Hello :)

https://stackoverflow.com/questions/26148418/jetty-9-setting-up-handlers-and-connectors talks about setting up a handler that is only used to respond to requests on a specific connector:

 

    ServerConnector httpConnector = new ServerConnector(server);

    httpConnector.setName("unsecured"); // named connector

    httpConnector.setPort(80);

 

    ContextHandler helloHandler = new ContextHandler();

    helloHandler.setContextPath("/hello");

    helloHandler.setHandler(new HelloHandler("Hello World"));

    helloHandler.setVirtualHosts(new String[]{"@unsecured"});

 

Does this work out of the box for web app contexts? Part of my code follows:

 

ServerConnector sslConnector = new ServerConnector(s,
     
new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()),
     
new HttpConnectionFactory(sslHttpConfig));
sslConnector.setName(
"https");
sslConnector.setHost("0.0.0.0");
sslConnector.setPort(
443);

 

ServerConnector nonSslConnector = new ServerConnector(s,
     
new HttpConnectionFactory(),
     
new HttpConnectionFactory(nonSslHttpConfig));
nonSslConnector.setName(
"http");
nonSslConnector.setHost(
"0.0.0.0");
nonSslConnector.setPort(
80);

 

WebAppContext t1 = new WebAppContext();
t1.setContextPath(
"/");
t1.setDisplayName(
"abc");
t1.setWar(
"c:/TempWebapp-1.0.war");
t1.setVirtualHosts(
new String[] {"@https","admin.bamidbarconnect.com","test2.local"});
WebAppContext t2 =
new WebAppContext();
t2.setContextPath(
"/");
t2.setResourceBase(
"c:/TempWebapp2/");
t2.setParentLoaderPriority(
true);
t2.setVirtualHosts(
new String[] {"@http","test1.local"});

s.setConnectors(
new Connector[]{nonSslConnector, sslConnector});

HandlerList list =
new HandlerList();
list.addHandler(t1);
list.addHandler(t2);

s.setHandler(list);

 

If it’s supposed to work, it doesn’t seem to be working for me. T1 is only supposed to be served via the SSL connector on port 443 and T2 is only supposed to be served on the non-SSL connector on port 80.

 

Thanks

--Steve

 

--

Lobos Studios | Phone: 877.919.4WEB | LobosStudios.com | Facebook.com/LobosStudios | @LobosStudios

Web Development - Mobile Development - Helpdesk/Tech Support - Computer Sales & Service

Acer Authorized Reseller - Computers, Windows and Android Tablets, Accessories

 

Steve Sobol - CEO, Senior Developer and Server Jockey

[hidden email]

 


_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users


_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: Binding a WebAppContext to a specific connector?

Greg Wilkins
Steve,

I will test the name only shortly.... but at a certain point, if you want a webapp to respond to just one connector, then it's simplest to create a new server that just binds the two of them.

On 24 March 2018 at 02:07, Steve Sobol - Lobos Studios <[hidden email]> wrote:
It didn’t seem to work when I only used the connector names, either.




On Fri, Mar 23, 2018 at 7:38 AM -0700, "Steve Sobol - Lobos Studios" <[hidden email]> wrote:

So if I want a WebAppContext to serve my app only for certain hostnames and only on one connector, that isn’t possible?




On Fri, Mar 23, 2018 at 2:59 AM -0700, "Joakim Erdfelt" <[hidden email]> wrote:

virtualHosts are not AND logic, they are OR logic.

Said another way, if you have a context.virtualHosts, then the incoming request MUST match ONE of the virtualHosts entries.

- Joakim

Joakim Erdfelt / [hidden email]

On Thu, Mar 22, 2018 at 11:06 PM, Steve Sobol - Lobos Studios <[hidden email]> wrote:

Hello :)

https://stackoverflow.com/questions/26148418/jetty-9-setting-up-handlers-and-connectors talks about setting up a handler that is only used to respond to requests on a specific connector:

 

    ServerConnector httpConnector = new ServerConnector(server);

    httpConnector.setName("unsecured"); // named connector

    httpConnector.setPort(80);

 

    ContextHandler helloHandler = new ContextHandler();

    helloHandler.setContextPath("/hello");

    helloHandler.setHandler(new HelloHandler("Hello World"));

    helloHandler.setVirtualHosts(new String[]{"@unsecured"});

 

Does this work out of the box for web app contexts? Part of my code follows:

 

ServerConnector sslConnector = new ServerConnector(s,
     
new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()),
     
new HttpConnectionFactory(sslHttpConfig));
sslConnector.setName(
"https");
sslConnector.setHost("0.0.0.0");
sslConnector.setPort(
443);

 

ServerConnector nonSslConnector = new ServerConnector(s,
     
new HttpConnectionFactory(),
     
new HttpConnectionFactory(nonSslHttpConfig));
nonSslConnector.setName(
"http");
nonSslConnector.setHost(
"0.0.0.0");
nonSslConnector.setPort(
80);

 

WebAppContext t1 = new WebAppContext();
t1.setContextPath(
"/");
t1.setDisplayName(
"abc");
t1.setWar(
"c:/TempWebapp-1.0.war");
t1.setVirtualHosts(
new String[] {"@https","admin.bamidbarconnect.com","test2.local"});
WebAppContext t2 =
new WebAppContext();
t2.setContextPath(
"/");
t2.setResourceBase(
"c:/TempWebapp2/");
t2.setParentLoaderPriority(
true);
t2.setVirtualHosts(
new String[] {"@http","test1.local"});

s.setConnectors(
new Connector[]{nonSslConnector, sslConnector});

HandlerList list =
new HandlerList();
list.addHandler(t1);
list.addHandler(t2);

s.setHandler(list);

 

If it’s supposed to work, it doesn’t seem to be working for me. T1 is only supposed to be served via the SSL connector on port 443 and T2 is only supposed to be served on the non-SSL connector on port 80.

 

Thanks

--Steve

 

--

Lobos Studios | Phone: 877.919.4WEB | LobosStudios.com | Facebook.com/LobosStudios | @LobosStudios

Web Development - Mobile Development - Helpdesk/Tech Support - Computer Sales & Service

Acer Authorized Reseller - Computers, Windows and Android Tablets, Accessories

 

Steve Sobol - CEO, Senior Developer and Server Jockey

[hidden email]

 


_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users


_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users



--

_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: Binding a WebAppContext to a specific connector?

Greg Wilkins
I just did a simple test based on the ManyServletContext example class and it works fine for me.

If  you are still having trouble with the mechanism, can you do a little hello world style example to demonstrate the problem?

cheers


On 27 March 2018 at 08:32, Greg Wilkins <[hidden email]> wrote:
Steve,

I will test the name only shortly.... but at a certain point, if you want a webapp to respond to just one connector, then it's simplest to create a new server that just binds the two of them.

On 24 March 2018 at 02:07, Steve Sobol - Lobos Studios <[hidden email]> wrote:
It didn’t seem to work when I only used the connector names, either.




On Fri, Mar 23, 2018 at 7:38 AM -0700, "Steve Sobol - Lobos Studios" <[hidden email]> wrote:

So if I want a WebAppContext to serve my app only for certain hostnames and only on one connector, that isn’t possible?




On Fri, Mar 23, 2018 at 2:59 AM -0700, "Joakim Erdfelt" <[hidden email]> wrote:

virtualHosts are not AND logic, they are OR logic.

Said another way, if you have a context.virtualHosts, then the incoming request MUST match ONE of the virtualHosts entries.

- Joakim

Joakim Erdfelt / [hidden email]

On Thu, Mar 22, 2018 at 11:06 PM, Steve Sobol - Lobos Studios <[hidden email]> wrote:

Hello :)

https://stackoverflow.com/questions/26148418/jetty-9-setting-up-handlers-and-connectors talks about setting up a handler that is only used to respond to requests on a specific connector:

 

    ServerConnector httpConnector = new ServerConnector(server);

    httpConnector.setName("unsecured"); // named connector

    httpConnector.setPort(80);

 

    ContextHandler helloHandler = new ContextHandler();

    helloHandler.setContextPath("/hello");

    helloHandler.setHandler(new HelloHandler("Hello World"));

    helloHandler.setVirtualHosts(new String[]{"@unsecured"});

 

Does this work out of the box for web app contexts? Part of my code follows:

 

ServerConnector sslConnector = new ServerConnector(s,
     
new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()),
     
new HttpConnectionFactory(sslHttpConfig));
sslConnector.setName(
"https");
sslConnector.setHost("0.0.0.0");
sslConnector.setPort(
443);

 

ServerConnector nonSslConnector = new ServerConnector(s,
     
new HttpConnectionFactory(),
     
new HttpConnectionFactory(nonSslHttpConfig));
nonSslConnector.setName(
"http");
nonSslConnector.setHost(
"0.0.0.0");
nonSslConnector.setPort(
80);

 

WebAppContext t1 = new WebAppContext();
t1.setContextPath(
"/");
t1.setDisplayName(
"abc");
t1.setWar(
"c:/TempWebapp-1.0.war");
t1.setVirtualHosts(
new String[] {"@https","admin.bamidbarconnect.com","test2.local"});
WebAppContext t2 =
new WebAppContext();
t2.setContextPath(
"/");
t2.setResourceBase(
"c:/TempWebapp2/");
t2.setParentLoaderPriority(
true);
t2.setVirtualHosts(
new String[] {"@http","test1.local"});

s.setConnectors(
new Connector[]{nonSslConnector, sslConnector});

HandlerList list =
new HandlerList();
list.addHandler(t1);
list.addHandler(t2);

s.setHandler(list);

 

If it’s supposed to work, it doesn’t seem to be working for me. T1 is only supposed to be served via the SSL connector on port 443 and T2 is only supposed to be served on the non-SSL connector on port 80.

 

Thanks

--Steve

 

--

Lobos Studios | Phone: 877.919.4WEB | LobosStudios.com | Facebook.com/LobosStudios | @LobosStudios

Web Development - Mobile Development - Helpdesk/Tech Support - Computer Sales & Service

Acer Authorized Reseller - Computers, Windows and Android Tablets, Accessories

 

Steve Sobol - CEO, Senior Developer and Server Jockey

[hidden email]

 


_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users


_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users



--



--

_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: Binding a WebAppContext to a specific connector?

Joakim Erdfelt-8

Joakim Erdfelt / [hidden email]

On Mon, Mar 26, 2018 at 4:44 PM, Greg Wilkins <[hidden email]> wrote:
I just did a simple test based on the ManyServletContext example class and it works fine for me.

If  you are still having trouble with the mechanism, can you do a little hello world style example to demonstrate the problem?

cheers


On 27 March 2018 at 08:32, Greg Wilkins <[hidden email]> wrote:
Steve,

I will test the name only shortly.... but at a certain point, if you want a webapp to respond to just one connector, then it's simplest to create a new server that just binds the two of them.

On 24 March 2018 at 02:07, Steve Sobol - Lobos Studios <[hidden email]> wrote:
It didn’t seem to work when I only used the connector names, either.




On Fri, Mar 23, 2018 at 7:38 AM -0700, "Steve Sobol - Lobos Studios" <[hidden email]> wrote:

So if I want a WebAppContext to serve my app only for certain hostnames and only on one connector, that isn’t possible?




On Fri, Mar 23, 2018 at 2:59 AM -0700, "Joakim Erdfelt" <[hidden email]> wrote:

virtualHosts are not AND logic, they are OR logic.

Said another way, if you have a context.virtualHosts, then the incoming request MUST match ONE of the virtualHosts entries.

- Joakim

Joakim Erdfelt / [hidden email]

On Thu, Mar 22, 2018 at 11:06 PM, Steve Sobol - Lobos Studios <[hidden email]> wrote:

Hello :)

https://stackoverflow.com/questions/26148418/jetty-9-setting-up-handlers-and-connectors talks about setting up a handler that is only used to respond to requests on a specific connector:

 

    ServerConnector httpConnector = new ServerConnector(server);

    httpConnector.setName("unsecured"); // named connector

    httpConnector.setPort(80);

 

    ContextHandler helloHandler = new ContextHandler();

    helloHandler.setContextPath("/hello");

    helloHandler.setHandler(new HelloHandler("Hello World"));

    helloHandler.setVirtualHosts(new String[]{"@unsecured"});

 

Does this work out of the box for web app contexts? Part of my code follows:

 

ServerConnector sslConnector = new ServerConnector(s,
     
new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()),
     
new HttpConnectionFactory(sslHttpConfig));
sslConnector.setName(
"https");
sslConnector.setHost("0.0.0.0");
sslConnector.setPort(
443);

 

ServerConnector nonSslConnector = new ServerConnector(s,
     
new HttpConnectionFactory(),
     
new HttpConnectionFactory(nonSslHttpConfig));
nonSslConnector.setName(
"http");
nonSslConnector.setHost(
"0.0.0.0");
nonSslConnector.setPort(
80);

 

WebAppContext t1 = new WebAppContext();
t1.setContextPath(
"/");
t1.setDisplayName(
"abc");
t1.setWar(
"c:/TempWebapp-1.0.war");
t1.setVirtualHosts(
new String[] {"@https","admin.bamidbarconnect.com","test2.local"});
WebAppContext t2 =
new WebAppContext();
t2.setContextPath(
"/");
t2.setResourceBase(
"c:/TempWebapp2/");
t2.setParentLoaderPriority(
true);
t2.setVirtualHosts(
new String[] {"@http","test1.local"});

s.setConnectors(
new Connector[]{nonSslConnector, sslConnector});

HandlerList list =
new HandlerList();
list.addHandler(t1);
list.addHandler(t2);

s.setHandler(list);

 

If it’s supposed to work, it doesn’t seem to be working for me. T1 is only supposed to be served via the SSL connector on port 443 and T2 is only supposed to be served on the non-SSL connector on port 80.

 

Thanks

--Steve

 

--

Lobos Studios | Phone: 877.919.4WEB | LobosStudios.com | Facebook.com/LobosStudios | @LobosStudios

Web Development - Mobile Development - Helpdesk/Tech Support - Computer Sales & Service

Acer Authorized Reseller - Computers, Windows and Android Tablets, Accessories

 

Steve Sobol - CEO, Senior Developer and Server Jockey

[hidden email]

 


_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users


_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users



--



--

_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users


_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: Binding a WebAppContext to a specific connector?

Jan Bartel
In reply to this post by Steve Sobol - Lobos Studios
Steve,

Jetty version? What other configuration? What urls did you try? What output did you get? Did you turn on debug?

I cut and pasted your code and tested against jetty-9.4.8, and it is working fine. I actually used 2 http ports instead of one https port, but I suspect that wouldn't make any difference.
I used port numbers 8080 (associated with the second context) and 9090 (associated with the first context), with these urls:

http://localhost:8080/   -> served only context two
http://localhost:9090/   -> served only context one

Jan

On 24 March 2018 at 02:07, Steve Sobol - Lobos Studios <[hidden email]> wrote:
It didn’t seem to work when I only used the connector names, either.




On Fri, Mar 23, 2018 at 7:38 AM -0700, "Steve Sobol - Lobos Studios" <[hidden email]> wrote:

So if I want a WebAppContext to serve my app only for certain hostnames and only on one connector, that isn’t possible?




On Fri, Mar 23, 2018 at 2:59 AM -0700, "Joakim Erdfelt" <[hidden email]> wrote:

virtualHosts are not AND logic, they are OR logic.

Said another way, if you have a context.virtualHosts, then the incoming request MUST match ONE of the virtualHosts entries.

- Joakim

Joakim Erdfelt / [hidden email]

On Thu, Mar 22, 2018 at 11:06 PM, Steve Sobol - Lobos Studios <[hidden email]> wrote:

Hello :)

https://stackoverflow.com/questions/26148418/jetty-9-setting-up-handlers-and-connectors talks about setting up a handler that is only used to respond to requests on a specific connector:

 

    ServerConnector httpConnector = new ServerConnector(server);

    httpConnector.setName("unsecured"); // named connector

    httpConnector.setPort(80);

 

    ContextHandler helloHandler = new ContextHandler();

    helloHandler.setContextPath("/hello");

    helloHandler.setHandler(new HelloHandler("Hello World"));

    helloHandler.setVirtualHosts(new String[]{"@unsecured"});

 

Does this work out of the box for web app contexts? Part of my code follows:

 

ServerConnector sslConnector = new ServerConnector(s,
     
new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()),
     
new HttpConnectionFactory(sslHttpConfig));
sslConnector.setName(
"https");
sslConnector.setHost("0.0.0.0");
sslConnector.setPort(
443);

 

ServerConnector nonSslConnector = new ServerConnector(s,
     
new HttpConnectionFactory(),
     
new HttpConnectionFactory(nonSslHttpConfig));
nonSslConnector.setName(
"http");
nonSslConnector.setHost(
"0.0.0.0");
nonSslConnector.setPort(
80);

 

WebAppContext t1 = new WebAppContext();
t1.setContextPath(
"/");
t1.setDisplayName(
"abc");
t1.setWar(
"c:/TempWebapp-1.0.war");
t1.setVirtualHosts(
new String[] {"@https","admin.bamidbarconnect.com","test2.local"});
WebAppContext t2 =
new WebAppContext();
t2.setContextPath(
"/");
t2.setResourceBase(
"c:/TempWebapp2/");
t2.setParentLoaderPriority(
true);
t2.setVirtualHosts(
new String[] {"@http","test1.local"});

s.setConnectors(
new Connector[]{nonSslConnector, sslConnector});

HandlerList list =
new HandlerList();
list.addHandler(t1);
list.addHandler(t2);

s.setHandler(list);

 

If it’s supposed to work, it doesn’t seem to be working for me. T1 is only supposed to be served via the SSL connector on port 443 and T2 is only supposed to be served on the non-SSL connector on port 80.

 

Thanks

--Steve

 

--

Lobos Studios | Phone: 877.919.4WEB | LobosStudios.com | Facebook.com/LobosStudios | @LobosStudios

Web Development - Mobile Development - Helpdesk/Tech Support - Computer Sales & Service

Acer Authorized Reseller - Computers, Windows and Android Tablets, Accessories

 

Steve Sobol - CEO, Senior Developer and Server Jockey

[hidden email]

 


_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users


_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users



--
Jan Bartel <[hidden email]>
www.webtide.com
Expert assistance from the creators of Jetty and CometD


_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: Binding a WebAppContext to a specific connector?

Steve Sobol - Lobos Studios
In reply to this post by Joakim Erdfelt-8

Actually, I came up with a solution. I subclassed WebAppContext and separated the check for the connector from the check for the virtual host names.

I can create a gist if you want to see what I did.

 

Thanks

 

--

Lobos Studios | Phone: 877.919.4WEB | LobosStudios.com | Facebook.com/LobosStudios | @LobosStudios

Web Development - Mobile Development - Helpdesk/Tech Support - Computer Sales & Service

Acer Authorized Reseller - Computers, Windows and Android Tablets, Accessories

 

Steve Sobol - CEO, Senior Developer and Server Jockey

[hidden email]

 

From: [hidden email] <[hidden email]> On Behalf Of Joakim Erdfelt
Sent: Monday, March 26, 2018 14:47
To: JETTY user mailing list <[hidden email]>
Subject: Re: [jetty-users] Binding a WebAppContext to a specific connector?

 

The cookbook has a basic example to start with ...

 

 

.. modify that to show your issue please.

 


Joakim Erdfelt / [hidden email]

 

On Mon, Mar 26, 2018 at 4:44 PM, Greg Wilkins <[hidden email]> wrote:

I just did a simple test based on the ManyServletContext example class and it works fine for me.

 

If  you are still having trouble with the mechanism, can you do a little hello world style example to demonstrate the problem?

 

cheers

 

 

On 27 March 2018 at 08:32, Greg Wilkins <[hidden email]> wrote:

Steve,

 

I will test the name only shortly.... but at a certain point, if you want a webapp to respond to just one connector, then it's simplest to create a new server that just binds the two of them.

 

On 24 March 2018 at 02:07, Steve Sobol - Lobos Studios <[hidden email]> wrote:

It didn’t seem to work when I only used the connector names, either.

 



On Fri, Mar 23, 2018 at 7:38 AM -0700, "Steve Sobol - Lobos Studios" <[hidden email]> wrote:

So if I want a WebAppContext to serve my app only for certain hostnames and only on one connector, that isn’t possible?

 



On Fri, Mar 23, 2018 at 2:59 AM -0700, "Joakim Erdfelt" <[hidden email]> wrote:

virtualHosts are not AND logic, they are OR logic.

 

Said another way, if you have a context.virtualHosts, then the incoming request MUST match ONE of the virtualHosts entries.

 

- Joakim


Joakim Erdfelt / [hidden email]

 

On Thu, Mar 22, 2018 at 11:06 PM, Steve Sobol - Lobos Studios <[hidden email]> wrote:

Hello :)

https://stackoverflow.com/questions/26148418/jetty-9-setting-up-handlers-and-connectors talks about setting up a handler that is only used to respond to requests on a specific connector:

 

    ServerConnector httpConnector = new ServerConnector(server);

    httpConnector.setName("unsecured"); // named connector

    httpConnector.setPort(80);

 

    ContextHandler helloHandler = new ContextHandler();

    helloHandler.setContextPath("/hello");

    helloHandler.setHandler(new HelloHandler("Hello World"));

    helloHandler.setVirtualHosts(new String[]{"@unsecured"});

 

Does this work out of the box for web app contexts? Part of my code follows:

 

ServerConnector sslConnector = new ServerConnector(s,
     
new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()),
     
new HttpConnectionFactory(sslHttpConfig));
sslConnector.setName(
"https");
sslConnector.setHost("0.0.0.0");
sslConnector.setPort(
443);

 

ServerConnector nonSslConnector = new ServerConnector(s,
     
new HttpConnectionFactory(),
     
new HttpConnectionFactory(nonSslHttpConfig));
nonSslConnector.setName(
"http");
nonSslConnector.setHost(
"0.0.0.0");
nonSslConnector.setPort(
80);

 

WebAppContext t1 = new WebAppContext();
t1.setContextPath(
"/");
t1.setDisplayName(
"abc");
t1.setWar(
"c:/TempWebapp-1.0.war");
t1.setVirtualHosts(
new String[] {"@https","admin.bamidbarconnect.com","test2.local"});
WebAppContext t2 =
new WebAppContext();
t2.setContextPath(
"/");
t2.setResourceBase(
"c:/TempWebapp2/");
t2.setParentLoaderPriority(
true);
t2.setVirtualHosts(
new String[] {"@http","test1.local"});

s.setConnectors(
new Connector[]{nonSslConnector, sslConnector});

HandlerList list =
new HandlerList();
list.addHandler(t1);
list.addHandler(t2);

s.setHandler(list);

 

If it’s supposed to work, it doesn’t seem to be working for me. T1 is only supposed to be served via the SSL connector on port 443 and T2 is only supposed to be served on the non-SSL connector on port 80.

 

Thanks

--Steve

 

--

Lobos Studios | Phone: 877.919.4WEB | LobosStudios.com | Facebook.com/LobosStudios | @LobosStudios

Web Development - Mobile Development - Helpdesk/Tech Support - Computer Sales & Service

Acer Authorized Reseller - Computers, Windows and Android Tablets, Accessories

 

Steve Sobol - CEO, Senior Developer and Server Jockey

[hidden email]

 


_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users

 


_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users



 

--



 

--


_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users

 


_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users
Reply | Threaded
Open this post in threaded view
|

Re: Binding a WebAppContext to a specific connector?

Steve Sobol - Lobos Studios
In reply to this post by Jan Bartel

I misspoke. If I just include the connector names, it works fine.

That still leaves the issue that I want to specify virtual hosts as well as connectors, but as I just mentioned, I came up with a solution for that, and can put my code online if anyone wants to see it.

 

Thanks

 

--

Lobos Studios | Phone: 877.919.4WEB | LobosStudios.com | Facebook.com/LobosStudios | @LobosStudios

Web Development - Mobile Development - Helpdesk/Tech Support - Computer Sales & Service

Acer Authorized Reseller - Computers, Windows and Android Tablets, Accessories

 

Steve Sobol - CEO, Senior Developer and Server Jockey

[hidden email]

 

From: [hidden email] <[hidden email]> On Behalf Of Jan Bartel
Sent: Monday, March 26, 2018 16:00
To: JETTY user mailing list <[hidden email]>
Subject: Re: [jetty-users] Binding a WebAppContext to a specific connector?

 

Steve,

 

Jetty version? What other configuration? What urls did you try? What output did you get? Did you turn on debug?

 

I cut and pasted your code and tested against jetty-9.4.8, and it is working fine. I actually used 2 http ports instead of one https port, but I suspect that wouldn't make any difference.

I used port numbers 8080 (associated with the second context) and 9090 (associated with the first context), with these urls:

 

http://localhost:8080/   -> served only context two

http://localhost:9090/   -> served only context one

 

Jan

 

On 24 March 2018 at 02:07, Steve Sobol - Lobos Studios <[hidden email]> wrote:

It didn’t seem to work when I only used the connector names, either.

 



On Fri, Mar 23, 2018 at 7:38 AM -0700, "Steve Sobol - Lobos Studios" <[hidden email]> wrote:

So if I want a WebAppContext to serve my app only for certain hostnames and only on one connector, that isn’t possible?

 



On Fri, Mar 23, 2018 at 2:59 AM -0700, "Joakim Erdfelt" <[hidden email]> wrote:

virtualHosts are not AND logic, they are OR logic.

 

Said another way, if you have a context.virtualHosts, then the incoming request MUST match ONE of the virtualHosts entries.

 

- Joakim


Joakim Erdfelt / [hidden email]

 

On Thu, Mar 22, 2018 at 11:06 PM, Steve Sobol - Lobos Studios <[hidden email]> wrote:

Hello :)

https://stackoverflow.com/questions/26148418/jetty-9-setting-up-handlers-and-connectors talks about setting up a handler that is only used to respond to requests on a specific connector:

 

    ServerConnector httpConnector = new ServerConnector(server);

    httpConnector.setName("unsecured"); // named connector

    httpConnector.setPort(80);

 

    ContextHandler helloHandler = new ContextHandler();

    helloHandler.setContextPath("/hello");

    helloHandler.setHandler(new HelloHandler("Hello World"));

    helloHandler.setVirtualHosts(new String[]{"@unsecured"});

 

Does this work out of the box for web app contexts? Part of my code follows:

 

ServerConnector sslConnector = new ServerConnector(s,
     
new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()),
     
new HttpConnectionFactory(sslHttpConfig));
sslConnector.setName(
"https");
sslConnector.setHost("0.0.0.0");
sslConnector.setPort(
443);

 

ServerConnector nonSslConnector = new ServerConnector(s,
     
new HttpConnectionFactory(),
     
new HttpConnectionFactory(nonSslHttpConfig));
nonSslConnector.setName(
"http");
nonSslConnector.setHost(
"0.0.0.0");
nonSslConnector.setPort(
80);

 

WebAppContext t1 = new WebAppContext();
t1.setContextPath(
"/");
t1.setDisplayName(
"abc");
t1.setWar(
"c:/TempWebapp-1.0.war");
t1.setVirtualHosts(
new String[] {"@https","admin.bamidbarconnect.com","test2.local"});
WebAppContext t2 =
new WebAppContext();
t2.setContextPath(
"/");
t2.setResourceBase(
"c:/TempWebapp2/");
t2.setParentLoaderPriority(
true);
t2.setVirtualHosts(
new String[] {"@http","test1.local"});

s.setConnectors(
new Connector[]{nonSslConnector, sslConnector});

HandlerList list =
new HandlerList();
list.addHandler(t1);
list.addHandler(t2);

s.setHandler(list);

 

If it’s supposed to work, it doesn’t seem to be working for me. T1 is only supposed to be served via the SSL connector on port 443 and T2 is only supposed to be served on the non-SSL connector on port 80.

 

Thanks

--Steve

 

--

Lobos Studios | Phone: 877.919.4WEB | LobosStudios.com | Facebook.com/LobosStudios | @LobosStudios

Web Development - Mobile Development - Helpdesk/Tech Support - Computer Sales & Service

Acer Authorized Reseller - Computers, Windows and Android Tablets, Accessories

 

Steve Sobol - CEO, Senior Developer and Server Jockey

[hidden email]

 


_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users

 


_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users



 

--

Jan Bartel <[hidden email]>

www.webtide.com
Expert assistance from the creators of Jetty and CometD

 


_______________________________________________
jetty-users mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users