nginx反向代理glassfish问题

我有nginx作为ssl的玻璃鱼服务器的反向代理服务,提供三个glassfish上下文,一个演示站点,一个jenkins和一个glassfishpipe理服务器。 根被redirect到演示站点。 Http被redirect到https,nginx做ssl卸载。 所有的工作都完美地解决了两个问题:

  1. 当第一次浏览演示网站(或删除浏览器历史logging后),我得到了glassfish的根,而不被redirect到https。 做一个刷新,我正确地redirect到https演示网站。
  2. 当浏览glassfishpipe理员时,我得到一个空白页面,pipe理页面的索引正确加载,但所有资源不加载(404)。 nginx错误日志给我显示以下错误: 2015/11/19 08:27:13 [error] 12656#0: *2 open() "/usr/share/nginx/html/resource/community-theme/images/login-product_name_open.png" failed (2: No such file or directory), client: <ip-address>, server: demo.domain.nl, request: "GET /resource/community-theme/images/login-product_name_open.png HTTP/1.1", host: "demo.domain.nl", referrer: "https://demo.domain.nl/admin/"

任何帮助非常感谢! 下面你可以find我的nginx conf:

  server { listen 80; listen [::]:80; server_name demo.domain.nl; return 301 https://$server_name$request_uri; } server { listen 443 default ssl; server_name demo.domain.nl; client_max_body_size 5M; ssl on; ssl_certificate conf.d/ssl/demo.domain.nl.crt; ssl_certificate_key conf.d/ssl/demo.domain.nl.key; ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers RC4:HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; keepalive_timeout 60; ssl_session_cache shared:SSL:10m; ssl_session_timeout 10m; access_log /var/log/nginx/demo.https.access_log; error_log /var/log/nginx/demo.https.error_log; rewrite_log on; location = / { rewrite ^ /demo/ last; } location /demo/ { proxy_pass http://localhost:8080/demo/; proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; proxy_set_header Accept-Encoding ""; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; add_header Front-End-Https on; proxy_redirect off; } location /jenkins/ { proxy_pass http://localhost:8080/jenkins/; proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; proxy_set_header Accept-Encoding ""; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; add_header Front-End-Https on; proxy_redirect off; } location /admin/ { proxy_pass https://localhost:4848/; proxy_redirect https://localhost:4848 https://demo.domain.nl/admin; proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; proxy_set_header Accept-Encoding ""; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; add_header Front-End-Https on; } } 

我有很多麻烦,使GF4.1pipe理控制台与Nginx的反向代理正常工作,所以留在这里,以防万一谁来看。

最大的麻烦不是使它工作,而是GlassFish的networking应用程序使用许多XMLHttpRequests,这使生活困难。 看下面的工作configuration。 我把8484作为一种“隐藏”的控制台来听,但是你可以听其他的东西,应该可以正常工作。 请注意,您可能不需要所有这些设置来使其工作。 我们对密码等的要求相当严格,但它会给你一个ssllabs的A +等级

 server { listen 8484; server_name yourdomain.com; ssl on; ssl_certificate /path/to/linked.crt; ssl_certificate_key /path/to/keyfile.key; ssl_session_cache shared:SSL:50m; ssl_session_timeout 5m; client_max_body_size 4G; ssl_protocols TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers On; ssl_ciphers 'kEECDH+ECDSA+AES128 kEECDH+ECDSA+AES256 kEECDH+AES128 kEECDH+AES256 kEDH+AES128 kEDH+AES256 !DES-CBC3-SHA +SHA !aNULL !eNULL !LOW !kECDH !DSS !MD5 !EXP !PSK !SRP !CAMELLIA !SEED'; ssl_dhparam /etc/nginx/ssl/dhparam2048.pem; #NB generate custom dhparam for logjam as follows: openssl dhparam -out dhparams.pem 2048 add_header Strict-Transport-Security 'max-age=31536000; includeSubDomains;'; ssl_stapling on; access_log /var/log/nginx/nginx-access.log; error_log /var/log/nginx/nginx-error.log; location / { proxy_connect_timeout 300; proxy_send_timeout 300; proxy_read_timeout 300; send_timeout 300; proxy_pass_request_headers on; proxy_no_cache $cookie_nocache $arg_nocache$arg_comment; proxy_no_cache $http_pragma $http_authorization; proxy_cache_bypass $cookie_nocache $arg_nocache $arg_comment; proxy_cache_bypass $http_pragma $http_authorization; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $host:$server_port; #Very nb to add :$server_port here proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; add_header Access-Control-Allow-Origin *; proxy_set_header Access-Control-Allow-Origin *; proxy_redirect /web/ https://yourdomain.com:8484/web/; #silly Xmlhttprequests proxy_pass https://127.0.0.1:4848; # proxy_ssl_verify off; #include this is using Nginx > 1.8 } }