nginx-1.23.3 on Win Server wth HTTPS

K
  • 18 Jan '23
Hello,

i will use nginx-1.23.3 on a Win Server, inclusiv HTTPS

After unpacking the ZIP file I have a "nginx.conf" file which I edit, from line 98, the HTTPS server block starts there.

I enter the absolute path to the CA and KEY file (Windows like path) but NGINX refuses to accept HTTPS.

I restart NGINX from CMD =>

C:\nginx\nginx-1.23.3>nginx -s reload
nginx: [emerg] unknown directive "HTTPS" in C:\nginx\nginx-1.23.3/conf/nginx.conf:98

I test with c:\CERT\my_cert
I test with CERT/my_cert

Both does not work

What do I have to do so that NGINX also accepts HTTPS connections?

Thanks

Michael

Berufsförderungswerk Berlin-Brandenburg e. V.
Epiphanienweg 1, 14059 Berlin
Telefon: +49 30 30399 0
<tel:+49%2030%20303990>info at bfw-berlin-brandenburg.de<mailto:info at bfw-berlin-brandenburg.de>
www.bfw-berlin-brandenburg.de
Amtsgericht Charlottenburg
VR 3642 Nz, Steuer-Nr. 27/661/55590
Vorstandsvorsitzender: Stefan Moschko
Geschäftsführung: Thomas Kastner, Andreas Braatz
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bak.nginx.conf
Type: application/octet-stream
Size: 2773 bytes
Desc: bak.nginx.conf
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20230118/e8c23988/attachment.obj>
F
  • 18 Jan '23
On Wed, Jan 18, 2023 at 08:51:18AM +0000, Kappes, Michael wrote:

Hi there,

> After unpacking the ZIP file I have a "nginx.conf" file which I edit, from line 98, the HTTPS server block starts there.

> C:\nginx\nginx-1.23.3>nginx -s reload
> nginx: [emerg] unknown directive "HTTPS" in C:\nginx\nginx-1.23.3/conf/nginx.conf:98

In that file,

    # HTTPS server

is a comment that should stay a comment.

You should uncomment and adjust the relevant lines that go from

    # server {

to the matching

    # }

> What do I have to do so that NGINX also accepts HTTPS connections?

Have a "listen" with "ssl", and the correct certificate information.

http://nginx.org/en/docs/http/configuring_https_servers.html

Good luck with it,

    f
-- 
Francis Daly        francis at daoine.org
K
  • 18 Jan '23
Hello Francis
Dear readers,

Thanks for Help!

OK, the # stay on HTTPS ;-)

My "correct certificate information" is the Problem. Nginx tells me:

invalid number of arguments in "ssl_certificate" directive in C:\nginx\nginx-1.23.3/conf/nginx.conf:102
(please note: "\" and "/" in the same path?!)

C:\nginx\nginx-1.23.3\cert\ => here a my cert and key files
At my nginx.conf file (the syntax) =>

        ssl_certificate      C:\nginx\nginx-1.23.3\cert\1-Servername.cert.pem;
        ssl_certificate_key  C:\nginx\nginx-1.23.3\cert\1-Servername.cert.key;

I have tested both

C:\nginx\nginx-1.23.3\cert\

And also

C:/nginx/nginx-1.23.3/cert/

Both won't work...

Or, i make a temp folder ( for testing)

At my nginx.conf file (the syntax) =>

        ssl_certificate      C:\temp\1-Servername.cert.pem;
        ssl_certificate_key  C:\temp\1-Servername.cert.key;

Also here, i change "\" to "/" without that it makes a difference

Strange
Michael

-----Ursprüngliche Nachricht-----
Von: nginx <nginx-bounces at nginx.org> Im Auftrag von Francis Daly
Gesendet: Mittwoch, 18. Januar 2023 12:02
An: nginx at nginx.org
Betreff: Re: nginx-1.23.3 on Win Server wth HTTPS

On Wed, Jan 18, 2023 at 08:51:18AM +0000, Kappes, Michael wrote:

Hi there,

> After unpacking the ZIP file I have a "nginx.conf" file which I edit, from line 98, the HTTPS server block starts there.

> C:\nginx\nginx-1.23.3>nginx -s reload
> nginx: [emerg] unknown directive "HTTPS" in C:\nginx\nginx-1.23.3/conf/nginx.conf:98

In that file,

# HTTPS server

is a comment that should stay a comment.

You should uncomment and adjust the relevant lines that go from

# server {

to the matching

# }

> What do I have to do so that NGINX also accepts HTTPS connections?

Have a "listen" with "ssl", and the correct certificate information.

http://nginx.org/en/docs/http/configuring_https_servers.html

Good luck with it,

f
--
Francis Daly        francis at daoine.org
_______________________________________________
nginx mailing list
nginx at nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx
Berufsförderungswerk Berlin-Brandenburg e. V.
Epiphanienweg 1, 14059 Berlin
Telefon: +49 30 30399 0
<tel:+49%2030%20303990>info at bfw-berlin-brandenburg.de<mailto:info at bfw-berlin-brandenburg.de>
www.bfw-berlin-brandenburg.de
Amtsgericht Charlottenburg
VR 3642 Nz, Steuer-Nr. 27/661/55590
Vorstandsvorsitzender: Stefan Moschko
Geschäftsführung: Thomas Kastner, Andreas Braatz
M
  • 18 Jan '23
Hello!

On Wed, Jan 18, 2023 at 12:41:32PM +0000, Kappes, Michael wrote:

> My "correct certificate information" is the Problem. Nginx tells me:
> 
> invalid number of arguments in "ssl_certificate" directive in C:\nginx\nginx-1.23.3/conf/nginx.conf:102
> (please note: "\" and "/" in the same path?!)

This works fine, since Windows interprets both "\" and "/" in 
places (including the functions nginx uses).

> C:\nginx\nginx-1.23.3\cert\ => here a my cert and key files
> At my nginx.conf file (the syntax) =>
> 
>         ssl_certificate      C:\nginx\nginx-1.23.3\cert\1-Servername.cert.pem;
>         ssl_certificate_key  C:\nginx\nginx-1.23.3\cert\1-Servername.cert.key;

When using "\" in nginx configuration, you have to be careful to 
properly escape it, since "\" is also an escape character, and, 
for example, "\n" will be interpreted as a newline character.  As 
such, using "/" is usually easier.

On the other hand, this particular issue does not explain why you 
are seeing the "invalid number of arguments" error, it should be 
"cannot load certificate" with a garbled certificate path instead.

The "invalid number of arguments" error suggests you've typed 
multiple arguments in the directive (instead of just one it 
accepts).  This usually happens if a space character is 
accidentally used where it shouldn't, but in the directives as 
shown certainly there are no extra space characters.

Most likely, there is an issue with the text editor you use, and 
it's somehow inserts some additional non-printable characters, 
such as byte order mark or something like that, and this confuses 
nginx.

What editor do you use?  Is using another one and re-typing the 
directives) makes a difference?  E.g., Notepad is usually 
available on Windows and does not seem to corrupt text files.

[...]

-- 
Maxim Dounin
http://mdounin.ru/
K
  • 19 Jan '23
Hello Maxim,

OK, i use notepad++ for editing
And yes, it was a problem with "some additional non-printable characters"

Now, all up and running

Ergo: Solved!

Big Thanks @all for Help
Michael

-----Ursprüngliche Nachricht-----
Von: nginx <nginx-bounces at nginx.org> Im Auftrag von Maxim Dounin
Gesendet: Mittwoch, 18. Januar 2023 20:31
An: nginx at nginx.org
Betreff: Re: AW: nginx-1.23.3 on Win Server wth HTTPS

Hello!

On Wed, Jan 18, 2023 at 12:41:32PM +0000, Kappes, Michael wrote:

> My "correct certificate information" is the Problem. Nginx tells me:
>
> invalid number of arguments in "ssl_certificate" directive in
> C:\nginx\nginx-1.23.3/conf/nginx.conf:102
> (please note: "\" and "/" in the same path?!)

This works fine, since Windows interprets both "\" and "/" in places (including the functions nginx uses).

> C:\nginx\nginx-1.23.3\cert\ => here a my cert and key files At my
> nginx.conf file (the syntax) =>
>
>         ssl_certificate      C:\nginx\nginx-1.23.3\cert\1-Servername.cert.pem;
>         ssl_certificate_key
> C:\nginx\nginx-1.23.3\cert\1-Servername.cert.key;

When using "\" in nginx configuration, you have to be careful to properly escape it, since "\" is also an escape character, and, for example, "\n" will be interpreted as a newline character.  As such, using "/" is usually easier.

On the other hand, this particular issue does not explain why you are seeing the "invalid number of arguments" error, it should be "cannot load certificate" with a garbled certificate path instead.

The "invalid number of arguments" error suggests you've typed multiple arguments in the directive (instead of just one it accepts).  This usually happens if a space character is accidentally used where it shouldn't, but in the directives as shown certainly there are no extra space characters.

Most likely, there is an issue with the text editor you use, and it's somehow inserts some additional non-printable characters, such as byte order mark or something like that, and this confuses nginx.

What editor do you use?  Is using another one and re-typing the
directives) makes a difference?  E.g., Notepad is usually available on Windows and does not seem to corrupt text files.

[...]

--
Maxim Dounin
http://mdounin.ru/
_______________________________________________
nginx mailing list
nginx at nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx
Berufsförderungswerk Berlin-Brandenburg e. V.
Epiphanienweg 1, 14059 Berlin
Telefon: +49 30 30399 0
<tel:+49%2030%20303990>info at bfw-berlin-brandenburg.de<mailto:info at bfw-berlin-brandenburg.de>
www.bfw-berlin-brandenburg.de
Amtsgericht Charlottenburg
VR 3642 Nz, Steuer-Nr. 27/661/55590
Vorstandsvorsitzender: Stefan Moschko
Geschäftsführung: Thomas Kastner, Andreas Braatz