Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] How do I serve https and http by one port

What I want to do is serving http and https at the same time for my jetty application. I have SelectChannelConnector and SslSocketConnector connectors and their ports are 3131 and 8443 respectively.

I would like to transparently forward requests

http://localhost:80/* --> http://localhost:3131/*
https://localhost:80/* --> https://localhost:8443/*

What is the easiest way to make it?

Thanks


_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/jetty-users


You cannot listen to the same port for both HTTP and HTTPS connections, you should sperate them, the default port for HTTPS is 443.

I don't know the Jetty way, but you can achieve desired effect using a reverse proxy (eg. nginx) in front of Jetty. There is an example configuration for nginx here: http://wiki.nginx.org/JavaServers#Configure_the_extensions_and_the_servlet_path_to_be_processed_by_the_Java_server

Another possible solution is to use port forwarding. If you are on Unix-like operating system you can forward ports by using built-in firewall (There should be similar tools for Windows). On Linux you can do this with iptables:

iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3131
iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 443 -j REDIRECT --to-port 8443

Here, eth0 is your public interface.

Hope this helps,
Emre.

Back to the top