0

我的应用程序可以在https://nocodefunctions.com/nocodeapp-web-front-1.0/访问

我希望它可以通过https://nocodefunctions.com和 http 版本访问:http: //nocodefunctions.com

我当前的 conf 不会导致预期的结果(取自此处):

upstream payara{
    least_conn;

    server localhost:8080 max_fails=3 fail_timeout=5s;
    server localhost:8181 max_fails=3 fail_timeout=5s;
}
server {
    if ($host = nocodefunctions.com) {
        return 301 https://$host/$request_uri;
    } # managed by Certbot


    listen        80;
    #Replace with your domain
    server_name   nocodefunctions.com;
    return        301 https://$host$request_uri;


}

server {
    listen        443 ssl;
    server_name   nocodefunctions.com;
    ssl_certificate /etc/letsencrypt/live/xxxxxxxxxxx # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/nocodefunctions.com/xxxxxxxxx # managed by Certbot

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";

    location / {
        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_pass http://payara;
    }
}

我使用 LetsEncrypt、Payara Micro。

4

1 回答 1

0

工作 nginx 配置:

upstream payara{
    least_conn;

    server localhost:8080 max_fails=3 fail_timeout=5s;
    server localhost:8181 max_fails=3 fail_timeout=5s;
}
server {
    if ($host = example.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    listen        80;
    #Replace with your domain
    server_name   example.com;
    return        301 https://$host$request_uri;


}

server {
    listen        443 ssl;
    server_name   example.com;
    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";

    location /name-of-deployed-payara-app {
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-Proto https;
            proxy_redirect off;
            proxy_connect_timeout      240;
            proxy_send_timeout         240;
            proxy_read_timeout         240;  
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_pass http://payara;
    }
    
    location = / {
            return 301 https://example.com/name-of-deployed-payara-app;
    }
}
于 2021-05-01T00:04:10.380 回答