2014-03-29 44 views
1

我用http://my-IP/發佈了一個獨立的web服務,它可以工作。java中的獨立ssl web服務

import javax.xml.ws.Endpoint; 

public class Publisher 
{ 
    public static void main(String[] args) throws Exception 
    { 

     Endpoint.publish("http://172.16.58.13/", new TicketQueryImpl()); 
     System.out.println("UP"); 

    } 
} 

現在我想使它成爲SSL併發布在https://my-IP/上。

我搜索了很多,但我沒有找到任何好的樣本或幫助。他們大多數不是爲獨立和使用Tomcat或其他服務器。任何機構都可以幫助我!

回答

2

SSL是一個非常複雜的野獸(從編程的一面)。爲什麼不使用類似於你的web服務的nginx或Apache代理請求?即它得到的SSL連接請求,並轉發到你的Web服務端口80

server { 
    listen    443 ssl; # Listen to SSL connections 
    ssl_certificate  www.example.com.crt; 
    ssl_certificate_key www.example.com.key; 
    ssl_protocols  SSLv3 TLSv1 TLSv1.1 TLSv1.2; 
    ssl_ciphers   HIGH:!aNULL:!MD5; 

    server_name   my-IP.com www.my-IP.com; 
    access_log   /var/log/nginx/example.com.access.log main; 
    access_log   /var/log/nginx/example.com.cache.log cache; 
    error_log   /var/log/nginx/example.com.error.log error; 

    location/{ 
     proxy_pass http://localhost:80; # Forward requests to your webservice 
    } 
    Include  /etc/nginx/proxy.conf; # Proxy configuration 
} 

又見http://nginx.org/en/docs/http/configuring_https_servers.html監聽的正確配置SSL服務器的更多信息。

+0

我沒有用過nginx,我下載了它。我怎麼能用這個代碼? –

+0

這將是一個網站的定義。例如,對於Linux中的nginx,你將不得不在/ etc/nginx/sites-available中添加一個包含這個定義的文件,然後在/ etc/nginx/sites-enabled(即'ln -s/etc/nginx/site-available/your-site-name/etc/nginx/sites-enabled/your-site-name「,然後重新啓動nginx,或者修改默認站點並重新啓動nginx。 –