0
|
1 #! /bin/sh |
|
2 |
|
3 # Redirect HTTP URLs to equivalent HTTPs when that seems to be the problem. |
|
4 # Turn on this kludge with |
|
5 # ErrorDocument 403 /cgi-bin/http2https |
|
6 # after installing this script in your CGI-bin directory. |
|
7 |
|
8 # Copyright (c) 2008 by Rhyolite Software, LLC |
|
9 # |
|
10 # This agreement is not applicable to any entity which sells anti-spam |
|
11 # solutions to others or provides an anti-spam solution as part of a |
|
12 # security solution sold to other entities, or to a private network |
|
13 # which employs the DCC or uses data provided by operation of the DCC |
|
14 # but does not provide corresponding data to other users. |
|
15 # |
|
16 # Permission to use, copy, modify, and distribute this software without |
|
17 # changes for any purpose with or without fee is hereby granted, provided |
|
18 # that the above copyright notice and this permission notice appear in all |
|
19 # copies and any distributed versions or copies are either unchanged |
|
20 # or not called anything similar to "DCC" or "Distributed Checksum |
|
21 # Clearinghouse". |
|
22 # |
|
23 # Parties not eligible to receive a license under this agreement can |
|
24 # obtain a commercial license to use DCC by contacting Rhyolite Software |
|
25 # at sales@rhyolite.com. |
|
26 # |
|
27 # A commercial license would be for Distributed Checksum and Reputation |
|
28 # Clearinghouse software. That software includes additional features. This |
|
29 # free license for Distributed ChecksumClearinghouse Software does not in any |
|
30 # way grant permision to use Distributed Checksum and Reputation Clearinghouse |
|
31 # software |
|
32 # |
|
33 # THE SOFTWARE IS PROVIDED "AS IS" AND RHYOLITE SOFTWARE, LLC DISCLAIMS ALL |
|
34 # WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES |
|
35 # OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL RHYOLITE SOFTWARE, LLC |
|
36 # BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES |
|
37 # OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, |
|
38 # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, |
|
39 # ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS |
|
40 # SOFTWARE. |
|
41 # Rhyolite Software DCC 1.3.103-1.6 $Revision$ |
|
42 |
|
43 |
|
44 # This script is only intended for 403 errors |
|
45 if test "$REDIRECT_STATUS" != "403"; then |
|
46 cat <<EOF |
|
47 Status: 500 Internal Server Error |
|
48 Content-type: text/html |
|
49 |
|
50 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> |
|
51 <HTML><HEAD> |
|
52 <TITLE>500 Internal Server Error</TITLE> |
|
53 </HEAD><BODY> |
|
54 <H1>Internal Server Error</H1> |
|
55 Invalid use of http2https for $REDIRECT_STATUS. |
|
56 <P><HR> |
|
57 <ADDRESS>$SERVER_SIGNATURE</ADDRESS> |
|
58 </BODY></HTML> |
|
59 EOF |
|
60 exit |
|
61 fi |
|
62 |
|
63 |
|
64 # if things seem to be happening with SSL, pretend we're not here |
|
65 if test "$REDIRECT_HTTPS" = "on"; then |
|
66 if test "$REDIRECT_ERROR_NOTES" = ""; then |
|
67 REDIRECT_ERROR_NOTES="You don't have permission to access $REQUEST_URI on this server." |
|
68 fi |
|
69 cat <<EOF |
|
70 Status: 403 Forbidden |
|
71 Content-type: text/html |
|
72 |
|
73 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> |
|
74 <HTML><HEAD> |
|
75 <TITLE>403 Forbidden</TITLE> |
|
76 </HEAD><BODY> |
|
77 <H1>Forbidden</H1> |
|
78 $REDIRECT_ERROR_NOTES |
|
79 <P><HR> |
|
80 <ADDRESS>$SERVER_SIGNATURE</ADDRESS> |
|
81 </BODY></HTML> |
|
82 EOF |
|
83 exit |
|
84 fi |
|
85 |
|
86 |
|
87 cat <<EOF |
|
88 Status: 301 Moved Permanently |
|
89 Location: https://$SERVER_NAME$REQUEST_URI |
|
90 Content-type: text/html |
|
91 |
|
92 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> |
|
93 <HTML><HEAD> |
|
94 <TITLE>HTTPS Required</TITLE> |
|
95 </HEAD><BODY> |
|
96 <H1>HTTPS Required</H1> |
|
97 You must use HTTPS to access $REQUEST_URI on this server. |
|
98 <P><HR> |
|
99 <ADDRESS>$SERVER_SIGNATURE</ADDRESS> |
|
100 </BODY></HTML> |
|
101 EOF |