Cuba platform behind Nginx for SSL

I’m trying to configure my app behind Nginx as a proxy with no success so far. This is the location block I’m using:


    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_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }

Connecting directly to Tomcat works fine, but with Nginx I keep getting "Failed to load the bootstrap javascript: ./VAADIN/vaadinBootstrap.js?v2017_03_28_11_25"
Do you have a working example of such a setup?
Thank you

Hello Paolo,

There is an example of CUBA application and Nginx configuration located on GitHub. The application was configured in the CUBA Studio:

Project Properties - Edit - Advanced - Modules prefix: board

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_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
}

Could you clarify the problem with SSL please? You mentioned it in the topic header.

Best regards,
Ivan

2 Likes

Dear Ivan, thanks a lot for your assistance. I’ve also posted a question on StackOverflow (I read somewhere you appreciate that) where I added some informations about my configuration.

I’m trying your project now, will get back asap

1 Like

I’m getting the same error with your app. I’m manually building the Cuba app on the server with gradle assemble/setupTomcat/deploy, don’t know if it’s relevant

Could you share with us your sample project please? We’ll check it and try to reproduce the error at our side. You may use a task zipProject and attach to the forum message or share github repo.

Mm, I just cloned your repo. This is my Nginx configuration:


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";
    }
}

Do you have the opportunity to test your project with SSL?

1 Like

I resolved this. It was a conflicting setting elsewhere in nginx configuration, that was managing static files

1 Like

Great news! From my side I could not reproduce this problem. Thank you for keeping us informed, Paolo.

I am trying to do something similar but my proxy_pass uses a different server (not localhost) and the problem is that the cookies do not pass and I always get “Session Expired” … I check with google chrome tools and there is no cookie set. How can I debug?

Thank you

The discussion of “Session Expired…” problem is continued here.