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

HTTP redirect server #26

Merged

Conversation

HenningHolmDE
Copy link
Contributor

It is a common use case that a web server that delivers content as HTTPS also supports redirecting from the HTTP protocol. This PR introduces a corresponding feature "HTTP redirect server" and contains the following changes:

  • Restructure launch of servers
    This change enables the possibility of launching multiple Iron server
    instances, which is required for implementing the redirect HTTP server.
  • Add redirect HTTP server
    When using TLS/SSL, it may be desired to run an additional HTTP server
    that redirects all requests to the TLS/SSL version of the website as a
    convenience for the users.
    This server is disabled by default and can be enabled using the
    tls_redirect_from option. The HTTPS host for the redirect can be set
    through the tls_redirect_dest option.

Feel free to comment any flaws of the implementation, I'm happy to improve it.

This closes #25.

This change enables the possibility of launching multiple Iron server
instances, which is required for implementing the redirect HTTP server.
When using TLS/SSL, it may be desired to run an additional HTTP server
that redirects all requests to the TLS/SSL version of the website as a
convenience for the users.
This server is disabled by default and can be enabled using the
tls_redirect_from option. The HTTPS host for the redirect can be set
through the tls_redirect_dest option.
@joseluisq joseluisq self-assigned this Jan 3, 2021
@joseluisq joseluisq added the enhancement New feature or request label Jan 3, 2021
@joseluisq joseluisq self-requested a review January 3, 2021 22:03
Copy link
Collaborator

@joseluisq joseluisq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks ok and a 308 is also fine.

~> static-web-server --port 443 --tls true --tls-pkcs12 dev.local-identity.p12 --tls-pkcs12-passwd my_password --tls-redirect-from 80 --tls-redirect-host dev.local
# 2021-01-04T01:56:21 [SERVER] - Static HTTPS Server "my-static-server" is listening on [::]:443
# 2021-01-04T01:56:21 [SERVER] - Redirect HTTP Server "my-static-server" is listening on [::]:80
~> curl -I http://dev.local
# HTTP/1.1 308 Permanent Redirect
# Location: https://dev.local/
# Content-Length: 0
# Date: Mon, 04 Jan 2021 00:56:25 GMT

@joseluisq joseluisq merged commit c4df0d3 into static-web-server:master Jan 4, 2021
@joseluisq
Copy link
Collaborator

Thanks!

@HenningHolmDE
Copy link
Contributor Author

You're welcome!

@joseluisq joseluisq added the v1 Deprecated v1, migrate to v2 instead label Jan 12, 2021
@joseluisq joseluisq added this to the v1.13.0 milestone Jan 12, 2021
@joseluisq
Copy link
Collaborator

New v1.13.0 released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request v1 Deprecated v1, migrate to v2 instead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for redirects from HTTP to HTTPS
2 participants