Question

I'am trying to include two project on my domain with the same lets-encrypt configuration but i got an error can't run nginx

**here is my default file **

HTTP — redirect all traffic to HTTPS

server { listen 80; listen [::]:80 default_server ipv6only=on; return 301 http://$host$request_uri; }

HTTPS — proxy all requests to the Node app

server { # Enable HTTP/2 listen 443 ssl http2; listen [::]:443 ssl http2; server_name test.example.com;

# Use the Let’s Encrypt certificates
ssl_certificate /etc/letsencrypt/live/test.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/test.example.com/privkey.pem;

# Include the SSL configuration from cipherli.st
include snippets/ssl-params.conf;

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:5000/;
    proxy_ssl_session_reuse off;
    proxy_set_header Host $http_host;
    proxy_cache_bypass $http_upgrade;
    proxy_redirect off; 
}

}

HTTPS — proxy all requests to the Node app

server { # Enable HTTP/2 listen 443 ssl http2; listen [::]:443 ssl http2; server_name test2.example.com;

# Use the Let’s Encrypt certificates
ssl_certificate /etc/letsencrypt/live/test.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/test.example.com/privkey.pem;

# Include the SSL configuration from cipherli.st
include snippets/ssl-params.conf;

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:5000/;
    proxy_ssl_session_reuse off;
    proxy_set_header Host $http_host;
    proxy_cache_bypass $http_upgrade;
    proxy_redirect off; 
}

}

**i am trying to include the new sub domain to certification

/opt/letsencrypt/certbot-auto --cert-name test.example.com -d test.example.com -d test1.example.com**

the error

nginx: [error] invalid PID number “” in “/run/nginx.pid” Encountered exception during recovery nginx restart failed:

Traceback (most recent call last): File “/opt/eff.org/certbot/venv/local/lib/python2.7/site-packages/certbot/error_handler.py”, line 103, in _call_registered self.funcs-1 File “/opt/eff.org/certbot/venv/local/lib/python2.7/site-packages/certbot/auth_handler.py”, line 308, in _cleanup_challenges self.auth.cleanup(achalls) File “/opt/eff.org/certbot/venv/local/lib/python2.7/site-packages/certbot_nginx/configurator.py”, line 1055, in cleanup self.restart() File “/opt/eff.org/certbot/venv/local/lib/python2.7/site-packages/certbot_nginx/configurator.py”, line 846, in restart nginx_restart(self.conf(‘ctl’), self.nginx_conf) File “/opt/eff.org/certbot/venv/local/lib/python2.7/site-packages/certbot_nginx/configurator.py”, line 1106, in nginx_restart “nginx restart failed:\n%s\n%s” % (out.read(), err.read())) MisconfigurationError: nginx restart failed:

An unexpected error occurred: UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xe2 in position 7: ordinal not in range(128)

both domain works but one with ssl and another without ssl and i am always getting error when trying to restart nginx

Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

i fixed the problem by remove all comments :) from nginx configuration

i removed this one # Use the Let’s Encrypt certificates

Thank you

i was not able to restart nginx but i found this command

sudo fuser -k 443/tcp service nginx restart

and now it’s working but still can’t add ssl certification

i got this error Failed to find executable apache2ctl in PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

and this

UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xe2 in position 7: ordinal not in range(128)

This comment has been deleted

From the errors you are seeing it looks like Nginx was not running on your system when you attempted to run LetsEncrypt. This is why the “invalid pid number” error shows up. Try running service nginx start before attempting to generate your certificate.