如何在 Ubuntu 上使用 Nginx 获取指向 pm2 应用程序的子域名?

如何在 Ubuntu 上使用 Nginx 获取指向 pm2 应用程序的子域名?

我有一个托管服务器,可以同时为域example.de和提供服务app.example.de

app.example.de希望我的 Metme/pm2 应用程序能够被使用。

我已经为 Nginx 创建了两个配置文件,但最终出现错误duplicate listen options for X.X.X.X:443

default配置:

server {
    listen example.de:80 default_server;
    root /var/www/html;
    index index.html index.htm index.nginx-debian.html;

    server_name example.de;

    location / {
            try_files $uri $uri/ =404;
    }
}

server {
    root /var/www/html;
    index index.html index.htm index.nginx-debian.html;
    server_name example.de; # managed by Certbot
    location / {
            try_files $uri $uri/ =404;
    }
    listen example.de:443 ssl ipv6only=on; # managed by Certbot
    
    ssl_certificate /etc/letsencrypt/live/example.de/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/example.de/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}

meteor配置

upstream app_nodejs {
    server app.example.de;
}

server {
    listen app.example.de:443 ssl ipv6only=on; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/example.de/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/example.de/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot   
    server_name app.example.de;

    if ($ssl_protocol = "") {
        rewrite ^   https://$server_name$request_uri? permanent;
    }

    location / {
         proxy_pass http://0.0.0.0:3000;
         include /etc/nginx/proxy_params;
    }
 }

我究竟做错了什么?

相关内容