Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify Nginx no-default sites for HTTPS #1414

Merged
merged 2 commits into from
Jul 27, 2022

Conversation

swalkinshaw
Copy link
Member

Nginx has a newer ssl_reject_handshake directive that lets us simplify the "no default" site conf. Before we had to generate a self-signed certificate just to satisfy Nginx and create a server that listened on port 443.

Now with ssl_reject_handshake, SSL handshakes with server names that are not part of the real WordPress server hosts will be rejected up front.

This means we can skip self-signed certificate generation in default cases. The two separate server configs (HTTP and HTTPS) have now been merged into one as well since they are simpler overall.

This was extracted from #1310 since it should be merged on its own.

Nginx has a newer `ssl_reject_handshake` directive that lets us simplify
the "no default" site conf. Before we had to generate a self-signed
certificate just to satisfy Nginx and create a server that listened on
port 443.

Now with `ssl_reject_handshake`, SSL handshakes with server names that
are *not* part of the real WordPress server hosts will be rejected up
front.

This means we can skip self-signed certificate generation in default
cases. The two separate server configs (HTTP and HTTPS) have now been
merged into one as well since they are simpler overall.
@swalkinshaw swalkinshaw merged commit 31d51a3 into master Jul 27, 2022
@swalkinshaw swalkinshaw deleted the simplify-nginx-no-default-site-ssl branch July 27, 2022 19:37
@dalepgrant
Copy link
Sponsor Contributor

Related Discourse thread for anyone ending up here looking for

non-zero return code
nginx: [emerg] duplicate listen options for [::]:443 in /etc/nginx/sites-enabled/ssl.no-default.conf:11
nginx: configuration file /etc/nginx/nginx.conf test failed

@swalkinshaw
Copy link
Member Author

Oh because the old conf/site was left behind and active 😓 Thanks for posting @dalepgrant

swalkinshaw added a commit that referenced this pull request Aug 4, 2022
#1414 simplified the Nginx
"no-default" site confs but broke backwards compatibility for existing
servers by leaving the old site enabled. This would result in Nginx failing
to restart because of duplicate listen options.

This keeps the `ssl.no-default.conf.j2` site conf but instead sets it to
disabled to prevent the duplicate listen options. Now there will only be
a single active site for "no-default" that contains both HTTP (port 80)
and HTTPS (port 443) listen options.
@swalkinshaw
Copy link
Member Author

#1415 should prevent the backwards compat issue once merged. Turned out to be simple and better ✨

@swalkinshaw swalkinshaw mentioned this pull request Feb 21, 2023
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants