Nginx不允许执行任何操作

时间:2018-11-02 18:29:00

标签: ubuntu ssl nginx

我有一个nginxubuntu上的ec2实例上运行。

我遵循此主题:

Nginx won't restart . . . Job for nginx.service failed because the control process exited with error code

但是,去年我已经运行了相同的服务,但是现在,当我尝试使用新的SSL文件更新我的pem配置时。我的Nginx服务器没有启动,重启或执行任何操作。

$ cat / etc / nginx / sites-available / default

##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##

# Default server configuration
#
server {
    listen 80 default_server;
    listen [::]:80 default_server;
#        root /home/ubuntu/viralapp;
        server_name howcanihelpyou.app;
        return 302 https://$server_name$request_uri;
}

server{
    # SSL configuration
    #
    listen 443 ssl http2 default_server;
    listen [::]:443 ssl http2 default_server;
        include snippets/self-signed.conf;
        include snippets/ssl-params.conf;
    #
    # Note: You should disable gzip for SSL traffic.
    # See: https://bugs.debian.org/773332
    #
    # Read up on ssl_ciphers to ensure a secure configuration.
    # See: https://bugs.debian.org/765782
    #
    # Self signed certs generated by the ssl-cert package
    # Don't use them in a production server!
    #
    # include snippets/snakeoil.conf;

    root /var/www/html;

    # Add index.php to the list if you are using PHP
    index index.html index.htm index.nginx-debian.html;

    server_name _;

    location / {
                proxy_pass http://localhost:3000;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection 'upgrade';
                proxy_set_header Host $host;
                proxy_cache_bypass $http_upgrade;

        # First attempt to serve request as file, then
        # as directory, then fall back to displaying a 404.
#TODO       try_files $uri $uri/ =404;
    }

        location /static {
#                alias /home/ubuntu/viralapp/public/;
        }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    #   include snippets/fastcgi-php.conf;
    #
    #   # With php7.0-cgi alone:
    #   fastcgi_pass 127.0.0.1:9000;
    #   # With php7.0-fpm:
    #   fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    #}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #   deny all;
    #}
}


# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
#server {
#   listen 80;
#   listen [::]:80;
#
#   server_name example.com;
#
#   root /var/www/example.com;
#   index index.html;
#
#   location / {
#       try_files $uri $uri/ =404;
#   }
#}

但是,现在要执行此操作:

service nginx restart
  

nginx.service的作业失败,因为控制进程退出   错误代码。请参阅“ systemctl状态nginx.service”和“ journalctl -xe”   有关详细信息。

或此操作:

$ systemctl status nginx.service

● nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Fri 2018-11-02 18:27:09 UTC; 1min 0s ago
  Process: 1740 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)

Nov 02 18:27:09 ip-172-31-27-80 systemd[1]: Stopped A high performance web server and a reverse proxy server.
Nov 02 18:27:09 ip-172-31-27-80 systemd[1]: Starting A high performance web server and a reverse proxy server...
Nov 02 18:27:09 ip-172-31-27-80 nginx[1740]: nginx: [emerg] PEM_read_bio_X509_AUX("/etc/ssl/certs/howcanihelpyou.app-cert.pem")
Nov 02 18:27:09 ip-172-31-27-80 nginx[1740]: nginx: configuration file /etc/nginx/nginx.conf test failed
Nov 02 18:27:09 ip-172-31-27-80 systemd[1]: nginx.service: Control process exited, code=exited status=1
Nov 02 18:27:09 ip-172-31-27-80 systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Nov 02 18:27:09 ip-172-31-27-80 systemd[1]: nginx.service: Unit entered failed state.
Nov 02 18:27:09 ip-172-31-27-80 systemd[1]: nginx.service: Failed with result 'exit-code'.

有人对如何解决它有想法?

0 个答案:

没有答案