Cuba on Tomkat with Nginx proxy server

It is very difficult for me to set up nginx as a proxy for Tomcat with Cuba Platform. I am using Nginx for SSL.

Nginx directive:

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 / tip / local.app.properties:

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

      

cat / conf / board core / local.app.properties:

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

      

Nginx access log:

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 access log:

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

      

Above, I have used "domain" instead of the actual domain. As you can see from the server directive, I already have a PHP application in the root.

I've already tried several options with no luck. I can access Tomcat, but I get a popup "Failed to load bootable javascript: ./ VAADIN / vaadinBootstrap.js? V2017_03_24_15_29"

Accessing Tomcat from outside on port 8080 without ssl works fine.

+3


source to share


1 answer


I recommend that you use the same / path in tomcat for your application and then you can configure it like:

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

      



See also: https://doc.cuba-platform.com/manual-6.4/server_push_settings.html for correct web socket configuration

+3


source







All Articles