Nginx代理的Tomcat上的Cuba

前端之家收集整理的这篇文章主要介绍了Nginx代理的Tomcat上的Cuba 前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我很难配置Nginx作为运行Cuba Platform的Tomcat的代理.我将Nginx用于SSL.

Nginx指令:

server {
    server_name test.domain.it   www.test.domain.it;
    access_log /var/log/Nginx/test.domain.it.access.log rt_cache;
    error_log /var/log/Nginx/test.domain.it.error.log;
    root /var/www/test.domain.it/htdocs/PHPApp/public;
    index index.PHP index.html index.htm;
    include common/PHP7.conf;  
    include common/locations-PHP7.conf;
    listen 443 ssl;
    ssl on;
    ssl_certificate     /etc/letsencrypt/live/test.domain.it/fullchain.pem;
    ssl_certificate_key     /etc/letsencrypt/live/test.domain.it/privkey.pem;

    location /board {
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_read_timeout     3600;
        proxy_connect_timeout  240;
        proxy_set_header Host $host;
        proxy_set_header X-RealIP $remote_addr;

        proxy_pass http://127.0.0.1:8080/board;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}

tomcat / conf / board / local.app.properties:

cuba.webHostName = test.domain.it
cuba.webAppUrl = https://test.domain.it/board
cuba.webContextName = board

tomcat / conf / board-core / local.app.properties:

cuba.webHostName = test.domain.it
cuba.automaticDatabaseUpdate = true
cuba.webAppUrl = https://test.domain.it/board

Nginx访问日志:

82.60.41.71 0.010 - [31/Mar/2017:15:13:21 +0200] test.k-rev.it "GET /board HTTP/1.1" 302 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML,like Gecko) Chrome/57.0.2987.110 Safari/537.36"
82.60.41.71 0.015 - [31/Mar/2017:15:13:21 +0200] test.k-rev.it "GET /board/ HTTP/1.1" 200 1033 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML,like Gecko) Chrome/57.0.2987.110 Safari/537.36"

Tomcat访问日志:

127.0.0.1 - - [31/Mar/2017:10:48:40 +0200] "GET /board HTTP/1.1" 302 -
127.0.0.1 - - [31/Mar/2017:10:48:40 +0200] "GET /board/ HTTP/1.1" 200 2349

上面我用“域”代替了实际的域.
从服务器指令可以看到,我的根目录上已经有一个程序.

我已经尝试了几种选择,但是没有运气.我可以访问Tomcat,但是弹出窗口“无法加载引导javascript:./VAADIN/vaadinBootstrap.js?v2017_03_24_15_29”

在没有ssl的情况下从端口8080外部访问Tomcat可以正常工作.

最佳答案
我建议您为应用程序在tomcat中使用相同的/ path,然后可以将位置设置为:

location /board {
    proxy_pass http://127.0.0.1:8080/board;
}

另请参阅:https://doc.cuba-platform.com/manual-6.4/server_push_settings.html,以获取正确的Web套接字推送配置

原文链接:https://www.f2er.com/nginx/532332.html

猜你在找的Nginx相关文章