绑定域名
<p>这里绑定的域名是针对自动脚本或者docker安装showdoc的情况。在绑定域名之前,请确保你已经安装好了showdoc服务,确保能通过http://127.0.0.1:4999 正常访问showdoc并创建文档。假如showdoc服务本身未成功,绑定域名可能会出现一些未知问题。</p>
<p>绑定域名的核心思路是利用nginx转发请求到4999端口。假如你要绑定域名是 <a href="http://test.showdoc.com.cn">http://test.showdoc.com.cn</a> ,则可以这样写nginx重定向规则:</p>
<pre><code>server {
listen 80;
server_name test.showdoc.com.cn;
client_max_body_size 1000m;
location ^~ / {
proxy_pass http://127.0.0.1:4999/;
proxy_redirect off;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header http_user_agent $http_user_agent;
}
}
</code></pre>
<p>假如你要安装到二级目录,如 <a href="http://test.showdoc.com.cn/showdoc/">http://test.showdoc.com.cn/showdoc/</a> ,则可以这样写:</p>
<pre><code>server {
listen 80;
server_name test.showdoc.com.cn;
client_max_body_size 1000m;
location ^~ /showdoc/ {
proxy_pass http://127.0.0.1:4999/;
proxy_redirect off;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header http_user_agent $http_user_agent;
}
# /server/路径和后面的/Public/路径重写是为了兼容历史
# 不设置这两条重写规则不影响showdoc主体使用,但可能图片和附件访问有问题。
location ^~ /server/ {
proxy_pass http://127.0.0.1:4999/server/;
proxy_redirect off;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header http_user_agent $http_user_agent;
}
location ^~ /Public/ {
proxy_pass http://127.0.0.1:4999/Public/;
proxy_redirect off;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header http_user_agent $http_user_agent;
}
}
</code></pre>