Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/nginx/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/EmptyTag/168.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
nginx服务器上的certbot安装问题_Nginx_Configuration_Certbot - Fatal编程技术网

nginx服务器上的certbot安装问题

nginx服务器上的certbot安装问题,nginx,configuration,certbot,Nginx,Configuration,Certbot,我跟随文章建立了2个Express.js网站。我成功地部署了这些网站,我可以将它们写入我的浏览器,以获得我想要的不同网站 http://myIpAdress:8080 http://myIpAdress:9000 我甚至将域名连接到ip地址,这样我就可以将这些域名写入我的浏览器,从而获得不同的网站。我只是隐藏了我的真实域名,并假设这些是真实的域名 http://myWebsite.com:8080 http://myWebsite2.com:9000 现在,下一步是安装nginx服务器,我也

我跟随文章建立了2个Express.js网站。我成功地部署了这些网站,我可以将它们写入我的浏览器,以获得我想要的不同网站

http://myIpAdress:8080
http://myIpAdress:9000
我甚至将域名连接到ip地址,这样我就可以将这些域名写入我的浏览器,从而获得不同的网站。我只是隐藏了我的真实域名,并假设这些是真实的域名

http://myWebsite.com:8080
http://myWebsite2.com:9000
现在,下一步是安装nginx服务器,我也成功地完成了这项工作。我取消了“/etc/nginx/sites available”下“default”文件的链接。我创建了两个不同的配置文件,分别命名为“myWebsite.com”和“myWebsite2.com”,并将它们链接起来

下一步是安装certbot文章中给出的说明有点过时,因为terminal告诉我,这种安装certbot的方式已被弃用

我找到了如何正确安装certbot的方法。但是,当我尝试编写此命令时,我遵循了以下命令:

$ sudo certbot certonly --nginx
它会抛出如下错误:

    Saving debug log to /var/log/letsencrypt/letsencrypt.log    
    Error while running nginx -c /etc/nginx/nginx.conf -t.
    
    nginx: [emerg] open() "/etc/letsencrypt/options-ssl-nginx.conf" failed (2: No such file or directory) in /etc/nginx/sites-enabled/myWebsite.com:19
    nginx: configuration file /etc/nginx/nginx.conf test failed
    
    Could not choose appropriate plugin: The nginx plugin is not working; there may be problems with your existing configuration.
    The error was: MisconfigurationError('Error while running nginx -c /etc/nginx/nginx.conf -t.\n\nnginx: [emerg] open() "/etc/letsencrypt/options-ssl-nginx.conf" failed (2: No such file or directory) in /etc/nginx/sites-enabled/myWebsite.com:19\nnginx: configuration file /etc/nginx/nginx.conf test failed\n')
    The nginx plugin is not working; there may be problems with your existing configuration.
    The error was: MisconfigurationError('Error while running nginx -c /etc/nginx/nginx.conf -t.\n\nnginx: [emerg] open() "/etc/letsencrypt/options-ssl-nginx.conf" failed (2: No such file or directory) in /etc/nginx/sites-enabled/myWebsite.com:19\nnginx: configuration file /etc/nginx/nginx.conf test failed\n')
我在这一点上被困了好几天

以下是我的配置文件“myWebsite.com”的内容:

谢谢你的帮助

server {
        root /var/www/html;      
        index index.html index.htm index.nginx-debian.html;
        server_name myWebsite.com;
         
location / {
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
       proxy_set_header X-NginX-Proxy true;
       proxy_pass http://localhost:8080;
       proxy_set_header Host $http_host;
       proxy_cache_bypass $http_upgrade;
       proxy_redirect off;
 }
    listen [::]:443 ssl; #ipv6only=on; # managed by Certbot
#   listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/myWebsite.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/myWebsite.com/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 {
    if ($host = myWebsite.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot
    
#       listen 80 default_server;
#       listen [::]:80 default_server;
        
        server_name myWebsite.com;
    return 404; # managed by Certbot
}