Starting to Write Again
It probably began with a sudden inspiration during the winter break, preparing to take care of my blog again.
It probably began with a sudden inspiration during the winter break, preparing to take care of my blog again.
The last time I seriously ran a blog was perhaps in middle school. Back then, I thought having a Blogger was cool, and having your own space for thoughts on the internet was great and trendy—I guess it’s not like that anymore?
CNBlogs urges everyone to turn off ad-blocking plugins, the atmosphere on CSDN in China keeps getting worse, and Bloggers have turned into Vloggers—why am I starting to take care of my blog again at this time?
I didn’t expect to encounter so many difficulties deploying Typecho… My previous setup was Nginx+MySQL+BaoTa, so you can understand that BaoTa had taken care of everything; all I needed to do was click the deployment button and it was ready to go.
So maybe the first thing I tried to do to become a True Blogger is to organize all the things myself.
I dropped Nginx for Caddy2 (isn’t this just asking for trouble? I couldn’t find any working URL rewrite configurations online after searching for days!) Of course, I thought about giving up (php-fpm configuration was fine, mysql configuration was fine, Caddy rewrite was fine and the homepage was accessible, but articles were unreadable? Login page worked but couldn’t log in?) In the end, the almighty Docker solved the problem, and I think it’s worth pasting the setup here for backup:
docker run -d \
--name=typecho-blog \
--restart always \
--mount type=tmpfs,destination=/tmp \
-v /root/Typecho-Files:/data \
-e PHP_TZ=Asia/Shanghai \
-e PHP_MAX_EXECUTION_TIME=600 \
-p 127.0.0.1:9080:80 \
80x86/typecho:latest
bashHere I didn’t expose the host port because I planned to use Caddy as a reverse proxy. When using Caddy as a reverse proxy, be aware of these two pitfalls I encountered (initially I could only access the homepage, but clicking on any content would redirect me to localhost:9080 which was inaccessible—how to solve it? Turns out I didn’t properly set X-Forwarded-Proto and X-Forwarded-Port):
- Check Typecho’s config.inc.php file to ensure that TYPECHO_SITE_URL is set to your public domain.
- In the Caddy configuration, make sure to set the correct X-Forwarded-For and X-Forwarded-Proto headers so Typecho knows the actual request protocol and client IP.
Your Caddy configuration should look like this:
YOUR_DOMAIN_GOES_HERE {
reverse_proxy http://localhost:9080 {
header_up Host {host}
header_up X-Forwarded-Host {host}
header_up X-Forwarded-For {remote_host}
header_up X-Forwarded-Proto {scheme}
}
tls YOUR_EMAIL_GOES_HERE
}
bashGreat, I finally have my own blog again. Hope I can write more in the future.