Last active
July 3, 2017 11:51
-
-
Save fukata/77d025e95a83235dbc0c to your computer and use it in GitHub Desktop.
Let's Encrypt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// ** MySQL settings - You can get this info from your web host ** // | |
/** The name of the database for WordPress */ | |
define('DB_NAME', ''); | |
/** MySQL database username */ | |
define('DB_USER', ''); | |
/** MySQL database password */ | |
define('DB_PASSWORD', ''); | |
/** MySQL hostname */ | |
define('DB_HOST', ''); | |
$connect = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); | |
if (!$connect) { | |
die("Can't connect database: " . mysql_error()); | |
} | |
if (!mysql_select_db(DB_NAME, $connect)) { | |
die("Could not select database"); | |
} | |
$tables = array("wp_posts"); // psots tables | |
foreach ($tables as $table) { | |
echo "table: $table\n"; | |
$select_sql = "select * from $table"; | |
$result = mysql_query($select_sql, $connect); | |
if (!$result) { | |
die("Select error: " . mysql_error()); | |
} | |
while ($row = mysql_fetch_assoc($result)) { | |
$content = $row["post_content"]; | |
$new_content = preg_replace("/http:\/\//", "https://", $content); | |
if ($new_content != $content) { | |
$post_id = $row["ID"]; | |
$update_sql = sprintf("update $table set post_content = '%s' where ID = '%s'", mysql_real_escape_string($new_content), mysql_real_escape_string($post_id)); | |
mysql_query($update_sql); | |
} | |
} | |
mysql_free_result($result); | |
} | |
mysql_close($connect); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Determine if SSL is used. | |
* | |
* @since 2.6.0 | |
* | |
* @return bool True if SSL, false if not used. | |
*/ | |
function is_ssl() { | |
if ( isset($_SERVER['HTTPS']) ) { | |
if ( 'on' == strtolower($_SERVER['HTTPS']) ) | |
return true; | |
if ( '1' == $_SERVER['HTTPS'] ) | |
return true; | |
} elseif ( isset($_SERVER['SERVER_PORT']) && ( '443' == $_SERVER['SERVER_PORT'] ) ) { | |
return true; | |
} | |
return false; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git clone https://github.com/letsencrypt/letsencrypt | |
cd letsencrypt | |
./letsencrypt-auto certonly \ | |
-d fukata.org \ | |
-d www.fukata.org \ | |
-d travel.fukata.org \ | |
-d camera.fukata.org \ | |
-d tabearuki.fukata.org \ | |
-d api.fukata.org \ | |
--server https://acme-v01.api.letsencrypt.org/directory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
location ~ \.php$ { | |
root /var/www/fukata.org; | |
include fastcgi_params; | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
fastcgi_pass 127.0.0.1:9000; | |
fastcgi_index index.php; | |
fastcgi_param SCRIPT_FILENAME /var/www/fukata.org/$fastcgi_script_name; | |
fastcgi_param HTTPS "on"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 443 ssl http2 default_server; | |
ssl_certificate /etc/letsencrypt/live/fukata.org/fullchain.pem; | |
ssl_certificate_key /etc/letsencrypt/live/fukata.org/privkey.pem; | |
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; | |
ssl_prefer_server_ciphers on; | |
ssl_ciphers AESGCM:HIGH:!aNULL:!MD5; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment