0

I keep getting errors when adding SSL syntax.

server {
listen 443 ssl;
server_name www.example.com;

ssl_certificate /etc/nginx/ssl/example.crt;
ssl_certificate_key /etc/nginx/ssl/example.key;


ssl_protocols SSLv3 TLSv1;

}

And also below CRT files, do I need to copy them to the /etc/nginx/ssl/ directory ?

AAA_Certificate_Services.crt
USERTrust_RSA_Certification_Authority.crt
Sectigo_RSA_Domain_Validation_Secure_Server_CA.crt

skb1-cct@skb1-cct:~$ journalctl  -xeu nginx.service
░░ Subject: A stop job for unit nginx.service has finished
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ A stop job for unit nginx.service has finished.
░░
░░ The job identifier is 40588 and the job result is done.
Aug 22 14:07:14 skb1-cct systemd[1]: Starting A high performance web server and a reverse proxy server...
░░ Subject: A start job for unit nginx.service has begun execution
░░ Defined-By: systemd
░░ Support: http://www.ubuntu.com/support
░░
░░ A start job for unit nginx.service has begun execution.
░░
░░ The job identifier is 40588.
Aug 22 14:07:14 skb1-cct nginx[140201]: nginx: [emerg] "server" directive is not allowed here in /etc/nginx/nginx.conf:63
Aug 22 14:07:14 skb1-cct nginx[140201]: nginx: configuration file /etc/nginx/nginx.conf test failed
Aug 22 14:07:14 skb1-cct systemd[1]: nginx.service: Control process exited, code=exited, status=1/FAILURE
░░ Subject: Unit process exited
░░ Defined-By: systemd
░░
░░
░░ An ExecStartPre= process belonging to unit nginx.service has exited.
░░
░░ The process' exit code is 'exited' and its exit status is 1.
Aug 22 14:07:14 skb1-cct systemd[1]: nginx.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ 
░░
░░ The unit nginx.service has entered the 'failed' state with result 'exit-code'.
Aug 22 14:07:14 skb1-cct systemd[1]: Failed to start A high performance web server and a reverse proxy server.
░░ Subject: A start job for unit nginx.service has failed
░░ Defined-By: systemd
░░ 
░░
░░ A start job for unit nginx.service has finished with a failure.
░░
░░ The job identifier is 40588 and the job result is failed.

http {

##
# Basic Settings
##

sendfile on;
tcp_nopush on;
types_hash_max_size 2048;
# server_tokens off;

# server_names_hash_bucket_size 64;
# server_name_in_redirect off;

include /etc/nginx/mime.types;
default_type application/octet-stream;

##
# SSL Settings
##
server {
listen 443 ssl;
server_name www.skb.skb-shutters.com

ssl_certificate /etc/nginx/ssl/skb_skb-shutters_com.crt;
ssl_certificate_key /etc/nginx/ssl/skb_skb-shutters_com.key;

ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;

}

##
# Logging Settings
##

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

##
# Gzip Settings
##

gzip on;

# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

##
# Virtual Host Configs
##

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;

}

9
  • "I keep getting error when adding SSL syntax." - what error? Also, please make yourself familiar with and apply proper formatting for code/config blocks. It is fairly easy and will improve readability of your question and thus willingness of others to help you. Commented Aug 22 at 5:17
  • Apologize, my first time adding SSL cert and also posting at the forum. Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xeu nginx.service" for details. what syntax should I write to query the detail error code ? Commented Aug 22 at 5:26
  • As the message says - "See "systemctl status nginx.service" and "journalctl -xeu nginx.service" for details. ". So do this and provide the output. And of course, the files you specify in your config must be actually available in the place you've specified. Commented Aug 22 at 5:50
  • 1
    @LokeWingKin: again, please learn to properly format. Also, the error message clearly says: "server" directive is not allowed here in /etc/nginx/nginx.conf:63. So you've added the section you've shown here in the wrong place. So the problem is not in what you've shown in your question but where you've placed it in the config - which you did not provide. Commented Aug 22 at 6:35
  • @LokeWingKin - simply indent the code block by four spaces. Alternatively, select the block you wish to format and click on the { } button (which does the indenting for you). I've done it for you. As you can see, it's much easier to read when correctly formatted :-) Commented Aug 22 at 6:45

1 Answer 1

0

You should try nginx -t which will show if any syntax error. Also you can check for the ssl file permissions, this should be 644.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .