| <!doctype html> |
| <html lang="en" dir="ltr" class="blog-wrapper blog-post-page plugin-blog plugin-id-default" data-has-hydrated="false"> |
| <head> |
| <meta charset="UTF-8"> |
| <meta name="generator" content="Docusaurus v3.1.1"> |
| <title data-rh="true">How to Access Answer Using HTTPS | Answer</title><meta data-rh="true" name="viewport" content="width=device-width,initial-scale=1"><meta data-rh="true" name="twitter:card" content="summary_large_image"><meta data-rh="true" property="og:url" content="https://answer.apache.org/blog/deploy-answer-https"><meta data-rh="true" property="og:locale" content="en"><meta data-rh="true" property="og:locale:alternate" content="zh_CN"><meta data-rh="true" name="docusaurus_locale" content="en"><meta data-rh="true" name="docusaurus_tag" content="default"><meta data-rh="true" name="docsearch:language" content="en"><meta data-rh="true" name="docsearch:docusaurus_tag" content="default"><meta data-rh="true" name="keywords" content="Free, Open-source, Q&A Platform, Knowledge Sharing Platform, Community Forum, Knowledge Base, Developer Hub, Support Center"><meta data-rh="true" property="og:site_name" content="Answer"><meta data-rh="true" property="og:type" content="article"><meta data-rh="true" property="og:title" content="How to Access Answer Using HTTPS | Answer"><meta data-rh="true" name="description" content="Got your Answer server up and running? Now, let's take it to the next level with HTTPS with the tutorials."><meta data-rh="true" property="og:description" content="Got your Answer server up and running? Now, let's take it to the next level with HTTPS with the tutorials."><meta data-rh="true" property="og:image" content="https://answer.apache.org/assets/images/2024-01-26-cover@4x-98b5a0c4083d0b68c192f8fd06548e1a.png"><meta data-rh="true" name="twitter:image" content="https://answer.apache.org/assets/images/2024-01-26-cover@4x-98b5a0c4083d0b68c192f8fd06548e1a.png"><meta data-rh="true" property="article:published_time" content="2024-01-26T00:00:00.000Z"><meta data-rh="true" property="article:author" content="https://github.com/LinkinStars"><link data-rh="true" rel="icon" href="/img/favicon.ico"><link data-rh="true" rel="canonical" href="https://answer.apache.org/blog/deploy-answer-https"><link data-rh="true" rel="alternate" href="https://answer.apache.org/blog/deploy-answer-https" hreflang="en"><link data-rh="true" rel="alternate" href="https://answer.apache.org/zh-CN/blog/deploy-answer-https" hreflang="zh-CN"><link data-rh="true" rel="alternate" href="https://answer.apache.org/blog/deploy-answer-https" hreflang="x-default"><script data-rh="true">var _paq=window._paq=window._paq||[];_paq.push(["setDoNotTrack",!0]),_paq.push(["disableCookies"]),_paq.push(["trackPageView"]),_paq.push(["enableLinkTracking"]),function(){var a="https://analytics.apache.org/";_paq.push(["setTrackerUrl",a+"matomo.php"]),_paq.push(["setSiteId","75"]);var e=document,p=e.createElement("script"),t=e.getElementsByTagName("script")[0];p.async=!0,p.src=a+"matomo.js",t.parentNode.insertBefore(p,t)}()</script><link rel="search" type="application/opensearchdescription+xml" title="Apache Answer" href="/opensearch.xml"> |
| <link rel="alternate" type="application/rss+xml" href="/blog/rss.xml" title="Apache Answer RSS Feed"> |
| <link rel="alternate" type="application/atom+xml" href="/blog/atom.xml" title="Apache Answer Atom Feed"> |
| |
| |
| |
| <link rel="stylesheet" href="/fonts/fonts.css"><link rel="stylesheet" href="/assets/css/styles.dafb0c64.css"> |
| <script src="/assets/js/runtime~main.5c009e72.js" defer="defer"></script> |
| <script src="/assets/js/main.7aa7d472.js" defer="defer"></script> |
| </head> |
| <body class="navigation-with-keyboard"> |
| <script>!function(){function t(t){document.documentElement.setAttribute("data-theme",t)}var e=function(){try{return new URLSearchParams(window.location.search).get("docusaurus-theme")}catch(t){}}()||function(){try{return localStorage.getItem("theme")}catch(t){}}();t(null!==e?e:"light")}(),function(){try{const c=new URLSearchParams(window.location.search).entries();for(var[t,e]of c)if(t.startsWith("docusaurus-data-")){var a=t.replace("docusaurus-data-","data-");document.documentElement.setAttribute(a,e)}}catch(t){}}()</script><div id="__docusaurus"><div role="region" aria-label="Skip to main content"><a class="skipToContent_D8pK" href="#__docusaurus_skipToContent_fallback">Skip to main content</a></div><nav aria-label="Main" class="navbar navbar--fixed-top navbar--primary"><div class="navbar__inner"><div class="navbar__items"><button aria-label="Toggle navigation bar" aria-expanded="false" class="navbar__toggle clean-btn" type="button"><svg width="30" height="30" viewBox="0 0 30 30" aria-hidden="true"><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></button><a class="navbar__brand" href="/"><div class="navbar__logo"><img src="/img/logo.svg" alt="Answer Logo" class="themedImage_Pn4p themedImage--light_PnYV"><img src="/img/logo.svg" alt="Answer Logo" class="themedImage_Pn4p themedImage--dark_eYgw"></div></a><a class="navbar__item navbar__link" href="/docs">Docs<!-- --></a><a class="navbar__item navbar__link" href="/plugins">Plugins<!-- --></a><a aria-current="page" class="navbar__item navbar__link navbar__link--active" href="/blog">Blog<!-- --></a><a class="navbar__item navbar__link" href="/download">Download<!-- --></a><div class="navbar__item dropdown dropdown--hoverable"><a class="navbar__link" aria-haspopup="true" aria-expanded="false" role="button" href="/community/support">Community<!-- --></a><ul class="dropdown__menu"><li><a class="dropdown__link" href="/community/support">Support<!-- --></a></li><li><a href="https://meta.answer.dev" target="_blank" rel="noopener noreferrer" class="dropdown__link">Q&A Community<!-- --></a></li><li><a class="dropdown__link" href="/community/team">Team<!-- --></a></li><li><a class="dropdown__link" href="/community/security">Security<!-- --></a></li><li><a class="dropdown__link" href="/community/security-model">Security Model<!-- --></a></li><li><a class="dropdown__link" href="/community/contributing">Contributing<!-- --></a></li><li><a href="https://github.com/apache/answer/projects" target="_blank" rel="noopener noreferrer" class="dropdown__link">Roadmap<!-- --></a></li></ul></div><div class="navbar__item dropdown dropdown--hoverable"><a href="https://www.apache.org/" target="_blank" rel="noopener noreferrer" aria-haspopup="true" aria-expanded="false" role="button" class="navbar__link">ASF<!-- --></a><ul class="dropdown__menu"><li><a href="https://www.apache.org" target="_blank" rel="noopener noreferrer" class="dropdown__link">Foundation<!-- --></a></li><li><a href="https://www.apache.org/licenses/" target="_blank" rel="noopener noreferrer" class="dropdown__link">License<!-- --></a></li><li><a href="https://www.apache.org/events/current-event.html" target="_blank" rel="noopener noreferrer" class="dropdown__link">Events<!-- --></a></li><li><a href="https://www.apache.org/foundation/sponsorship.html" target="_blank" rel="noopener noreferrer" class="dropdown__link">Sponsorship<!-- --></a></li><li><a href="https://privacy.apache.org/policies/privacy-policy-public.html" target="_blank" rel="noopener noreferrer" class="dropdown__link">Privacy<!-- --></a></li><li><a class="dropdown__link" href="/community/security">Security<!-- --></a></li><li><a href="https://www.apache.org/foundation/thanks.html" target="_blank" rel="noopener noreferrer" class="dropdown__link">Thanks<!-- --></a></li></ul></div></div><div class="navbar__items navbar__items--right"><div class="navbar__item dropdown dropdown--hoverable dropdown--right"><a href="#" aria-haspopup="true" aria-expanded="false" role="button" class="navbar__link bi bi-translate"><svg viewBox="0 0 24 24" width="20" height="20" aria-hidden="true" class="iconLanguage_DSK9"><path fill="currentColor" d="M12.87 15.07l-2.54-2.51.03-.03c1.74-1.94 2.98-4.17 3.71-6.53H17V4h-7V2H8v2H1v1.99h11.17C11.5 7.92 10.44 9.75 9 11.35 8.07 10.32 7.3 9.19 6.69 8h-2c.73 1.63 1.73 3.17 2.98 4.56l-5.09 5.02L4 19l5-5 3.11 3.11.76-2.04zM18.5 10h-2L12 22h2l1.12-3h4.75L21 22h2l-4.5-12zm-2.62 7l1.62-4.33L19.12 17h-3.24z"></path></svg>English<!-- --></a><ul class="dropdown__menu"><li><a href="/blog/deploy-answer-https" target="_self" rel="noopener noreferrer" class="dropdown__link dropdown__link--active" lang="en">English<!-- --></a></li><li><a href="/zh-CN/blog/deploy-answer-https" target="_self" rel="noopener noreferrer" class="dropdown__link" lang="zh-CN">简体中文<!-- --></a></li></ul></div><a href="https://twitter.com/answerdev" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link bi bi-twitter-x navbar-icon-link"></a><a href="https://discord.gg/a6PZZbfnFx" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link bi bi-discord navbar-icon-link"></a><a href="https://github.com/apache/answer" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link bi bi-github navbar-icon-link"></a><div class="searchBox_H2mL"></div></div></div><div role="presentation" class="navbar-sidebar__backdrop"></div></nav><div id="__docusaurus_skipToContent_fallback" class="main-wrapper mainWrapper_eExm"><div class="container"><div class="justify-content-end mb-4 row"><div class="col-lg-8 col-md-12"><div class="px-0 px-lg-5 pt-5"><header><div class="d-flex align-items-center mb-3"><a class="me-2" href="/blog">Blog<!-- --></a><span class="me-2">/</span><a class="me-2" href="/blog/category/tutorials">Tutorials<!-- --></a></div><h1 class="mb-3"><a class="text-body" href="/blog/deploy-answer-https">How to Access Answer Using HTTPS</a></h1><div class="d-flex align-items-center text-secondary"><div class="me-3">LinkinStar</div><time class="me-3" datetime="2024-01-26T00:00:00.000Z">January 26, 2024</time><div>3 min read<!-- --></div></div></header></div></div><div class="col-lg-2 col-md-12"></div></div><div class="justify-content-end row"><div class="col-lg-8 col-md-12"><article class="px-0 px-lg-5 pb-5 mb-5" itemprop="blogPost" itemscope="" itemtype="http://schema.org/BlogPosting"><meta itemprop="image" content="https://answer.apache.org/2024-01-26-cover@4x.png"><div id="__blog-post-container" class="markdown" itemprop="articleBody"><div class="mb-4"><img decoding="async" loading="lazy" src="/assets/images/2024-01-26-cover@4x-98b5a0c4083d0b68c192f8fd06548e1a.png" class="rounded img_RAU7" width="1280px" height="720px"></div><blockquote> |
| <!-- --><p>I am already running Answer on my server, but I want to access it using HTTPS. How can I do that?</p> |
| <!-- --></blockquote> |
| <!-- --><h2 class="anchor anchorWithStickyNavbar_loeA" id="background">Background<!-- --><a href="#background" class="hash-link" aria-label="Direct link to Background" title="Direct link to Background"></a></h2> |
| <!-- --><p>When you already have a server, you may want to deploy Answer on it. After deploying Answer, you will realize that you can only access it using HTTP. However, you may want to access it using HTTPS. So how can you do that?</p> |
| <!-- --><p>Some questions:</p> |
| <!-- --><ul> |
| <!-- --><li><a href="https://meta.answer.dev/questions/D1G3/how-to-configure-ssl" target="_blank" rel="noopener noreferrer">https://meta.answer.dev/questions/D1G3/how-to-configure-ssl</a></li> |
| <!-- --><li><a href="https://meta.answer.dev/questions/D1wh/how-to-enable-ssl" target="_blank" rel="noopener noreferrer">https://meta.answer.dev/questions/D1wh/how-to-enable-ssl</a></li> |
| <!-- --><li><a href="https://meta.answer.dev/questions/D1XG2/how-to-deploy-answer-image-in-aws-in-docker-with-ssl-and-nginx" target="_blank" rel="noopener noreferrer">https://meta.answer.dev/questions/D1XG2/how-to-deploy-answer-image-in-aws-in-docker-with-ssl-and-nginx</a></li> |
| <!-- --><li><a href="https://meta.answer.dev/questions/D136/how-to-deploy-an-ssl-certificate-using-docker-and-how-to-access-it-without-using-a-port" target="_blank" rel="noopener noreferrer">https://meta.answer.dev/questions/D136/how-to-deploy-an-ssl-certificate-using-docker-and-how-to-access-it-without-using-a-port</a></li> |
| <!-- --><li><a href="https://meta.answer.dev/questions/D1Oe/i-have-set-up-ssl-on-cloudflare-but-still-can-t-access-via-https" target="_blank" rel="noopener noreferrer">https://meta.answer.dev/questions/D1Oe/i-have-set-up-ssl-on-cloudflare-but-still-can-t-access-via-https</a></li> |
| <!-- --><li>...</li> |
| <!-- --></ul> |
| <!-- --><p>I found that many people have this question. Deploying Answer is easy, but deploying it with HTTPS is a bit difficult. So I decided to write this article to help you deploy Answer with HTTPS.</p> |
| <!-- --><h2 class="anchor anchorWithStickyNavbar_loeA" id="easy-way">Easy way<!-- --><a href="#easy-way" class="hash-link" aria-label="Direct link to Easy way" title="Direct link to Easy way"></a></h2> |
| <!-- --><p>This blog aims to introduce the easiest way to deploy Answer with HTTPS. You can use <!-- --><a href="https://caddyserver.com/" target="_blank" rel="noopener noreferrer">Caddy</a> to deploy Answer with HTTPS. Caddy is a powerful, enterprise-ready, open source web server with automatic HTTPS written in Go. Of course, you can use other tools to deploy Answer with HTTPS, such as Nginx, etc.<!-- --></p> |
| <!-- --><h2 class="anchor anchorWithStickyNavbar_loeA" id="preparation">Preparation<!-- --><a href="#preparation" class="hash-link" aria-label="Direct link to Preparation" title="Direct link to Preparation"></a></h2> |
| <!-- --><ol> |
| <!-- --><li> |
| <!-- --><p>You can follow the <!-- --><a href="https://answer.apache.org/docs/installation/" target="_blank" rel="noopener noreferrer">installation guide</a> to install Answer. After installing Answer, you can access it using HTTP. The default port for Answer is 9080. You can access it at <!-- --><a href="http://localhost:9080" target="_blank" rel="noopener noreferrer">http://localhost:9080</a>. In the following steps, we will use 9080 as the default port for Answer.<!-- --></p> |
| <!-- --></li> |
| <!-- --><li> |
| <!-- --><p>You need a domain that <!-- --><strong>DNS resolution is already configured to point to your server</strong>.<!-- --></p> |
| <!-- --></li> |
| <!-- --><li> |
| <!-- --><p>In this blog we will use docker-compose to install Caddy. So we need docker and docker-compose. You can follow the <!-- --><a href="https://docs.docker.com/engine/install/" target="_blank" rel="noopener noreferrer">official guide</a> to install docker and docker-compose.<!-- --></p> |
| <!-- --></li> |
| <!-- --></ol> |
| <!-- --><h2 class="anchor anchorWithStickyNavbar_loeA" id="deploy">Deploy<!-- --><a href="#deploy" class="hash-link" aria-label="Direct link to Deploy" title="Direct link to Deploy"></a></h2> |
| <!-- --><h3 class="anchor anchorWithStickyNavbar_loeA" id="step-1">Step 1<!-- --><a href="#step-1" class="hash-link" aria-label="Direct link to Step 1" title="Direct link to Step 1"></a></h3> |
| <!-- --><div class="language-shell codeBlockContainer_APcc theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_m3Ux"><pre tabindex="0" class="prism-code language-shell codeBlock_qGQc thin-scrollbar"><code class="codeBlockLines_p187"><span class="token-line" style="color:#393A34"><span class="token plain">$ </span><span class="token function" style="color:#d73a49">mkdir</span><span class="token plain"> caddy-docker</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">$ </span><span class="token builtin class-name">cd</span><span class="token plain"> caddy-docker</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">$ </span><span class="token function" style="color:#d73a49">vim</span><span class="token plain"> docker-compose.yml</span><br></span></code></pre><div class="buttonGroup_6DOT"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_FhaS" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_phi_"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_FfTR"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div> |
| <!-- --><p>You can create a <!-- --><code>docker-compose.yml</code> file in the new directory, and then add the following code:<!-- --></p> |
| <!-- --><div class="language-yaml codeBlockContainer_APcc theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockTitle_P25_">docker-compose.yml</div><div class="codeBlockContent_m3Ux"><pre tabindex="0" class="prism-code language-yaml codeBlock_qGQc thin-scrollbar"><code class="codeBlockLines_p187"><span class="token-line" style="color:#393A34"><span class="token key atrule" style="color:#00a4db">version</span><span class="token punctuation" style="color:#393A34">:</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"3.7"</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token key atrule" style="color:#00a4db">services</span><span class="token punctuation" style="color:#393A34">:</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> </span><span class="token key atrule" style="color:#00a4db">caddy</span><span class="token punctuation" style="color:#393A34">:</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> </span><span class="token key atrule" style="color:#00a4db">image</span><span class="token punctuation" style="color:#393A34">:</span><span class="token plain"> caddy</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> </span><span class="token key atrule" style="color:#00a4db">restart</span><span class="token punctuation" style="color:#393A34">:</span><span class="token plain"> unless</span><span class="token punctuation" style="color:#393A34">-</span><span class="token plain">stopped</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> </span><span class="token key atrule" style="color:#00a4db">ports</span><span class="token punctuation" style="color:#393A34">:</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">-</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"80:80"</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">-</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"443:443"</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">-</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"443:443/udp"</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> </span><span class="token key atrule" style="color:#00a4db">volumes</span><span class="token punctuation" style="color:#393A34">:</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">-</span><span class="token plain"> $PWD/Caddyfile</span><span class="token punctuation" style="color:#393A34">:</span><span class="token plain">/etc/caddy/Caddyfile</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">-</span><span class="token plain"> $PWD/caddy_data</span><span class="token punctuation" style="color:#393A34">:</span><span class="token plain">/data</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">-</span><span class="token plain"> $PWD/caddy_config</span><span class="token punctuation" style="color:#393A34">:</span><span class="token plain">/config</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> </span><span class="token key atrule" style="color:#00a4db">network_mode</span><span class="token punctuation" style="color:#393A34">:</span><span class="token plain"> host</span><br></span></code></pre><div class="buttonGroup_6DOT"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_FhaS" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_phi_"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_FfTR"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div> |
| <!-- --><h3 class="anchor anchorWithStickyNavbar_loeA" id="step-2">Step 2<!-- --><a href="#step-2" class="hash-link" aria-label="Direct link to Step 2" title="Direct link to Step 2"></a></h3> |
| <!-- --><p>The <!-- --><code>Caddyfile</code> is the configuration file for Caddy. It is used to configure how Caddy should serve your site. This file will be mounted into the container at <!-- --><code>/etc/caddy/Caddyfile</code>.<!-- --></p> |
| <!-- --><div class="language-shell codeBlockContainer_APcc theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_m3Ux"><pre tabindex="0" class="prism-code language-shell codeBlock_qGQc thin-scrollbar"><code class="codeBlockLines_p187"><span class="token-line" style="color:#393A34"><span class="token plain">$ </span><span class="token function" style="color:#d73a49">vim</span><span class="token plain"> Caddyfile</span><br></span></code></pre><div class="buttonGroup_6DOT"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_FhaS" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_phi_"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_FfTR"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div> |
| <!-- --><p>Create <!-- --><code>Caddyfile</code> file in the same directory, and then add the following code:<!-- --></p> |
| <!-- --><div class="language-text codeBlockContainer_APcc theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockTitle_P25_">Caddyfile</div><div class="codeBlockContent_m3Ux"><pre tabindex="0" class="prism-code language-text codeBlock_qGQc thin-scrollbar"><code class="codeBlockLines_p187"><span class="token-line" style="color:#393A34"><span class="token plain">your.answer.domain {</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> reverse_proxy 127.0.0.1:9080</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">}</span><br></span></code></pre><div class="buttonGroup_6DOT"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_FhaS" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_phi_"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_FfTR"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div> |
| <!-- --><h3 class="anchor anchorWithStickyNavbar_loeA" id="step-3">Step 3<!-- --><a href="#step-3" class="hash-link" aria-label="Direct link to Step 3" title="Direct link to Step 3"></a></h3> |
| <!-- --><p>Run the following command to start Caddy. Wait a few seconds, and then you can access Answer using HTTPS.</p> |
| <!-- --><div class="language-shell codeBlockContainer_APcc theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_m3Ux"><pre tabindex="0" class="prism-code language-shell codeBlock_qGQc thin-scrollbar"><code class="codeBlockLines_p187"><span class="token-line" style="color:#393A34"><span class="token plain">$ </span><span class="token function" style="color:#d73a49">docker-compose</span><span class="token plain"> up -d</span><br></span></code></pre><div class="buttonGroup_6DOT"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_FhaS" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_phi_"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_FfTR"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div> |
| <!-- --><p>If you can't access it, you can check the logs of Caddy.</p> |
| <!-- --><div class="language-shell codeBlockContainer_APcc theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_m3Ux"><pre tabindex="0" class="prism-code language-shell codeBlock_qGQc thin-scrollbar"><code class="codeBlockLines_p187"><span class="token-line" style="color:#393A34"><span class="token plain">$ </span><span class="token function" style="color:#d73a49">docker-compose</span><span class="token plain"> logs</span><br></span></code></pre><div class="buttonGroup_6DOT"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_FhaS" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_phi_"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_FfTR"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div> |
| <!-- --><h2 class="anchor anchorWithStickyNavbar_loeA" id="advanced">Advanced<!-- --><a href="#advanced" class="hash-link" aria-label="Direct link to Advanced" title="Direct link to Advanced"></a></h2> |
| <!-- --><p>If you don't want to use <!-- --><code>network_mode: host</code> in <!-- --><code>docker-compose.yml</code>, you can put Answer and Caddy in the same docker compose. Then Caddy and Answer can use the same network. So you can configure Caddy like this:<!-- --></p> |
| <!-- --><div class="language-text codeBlockContainer_APcc theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockTitle_P25_">Caddyfile</div><div class="codeBlockContent_m3Ux"><pre tabindex="0" class="prism-code language-text codeBlock_qGQc thin-scrollbar"><code class="codeBlockLines_p187"><span class="token-line" style="color:#393A34"><span class="token plain">your.answer.domain {</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"> reverse_proxy answer-service:9080</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">}</span><br></span></code></pre><div class="buttonGroup_6DOT"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_FhaS" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_phi_"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_FfTR"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div> |
| <!-- --><p>Of course, you can also install Caddy using other methods, such as using the binary file, etc. All in all, I wish you can follow this blog to deploy Answer with HTTPS successfully. If you have any questions, please feel free to leave a question on <!-- --><a href="https://meta.answer.dev/" target="_blank" rel="noopener noreferrer">Meta</a>. We will try our best to help you.<!-- --></p></div><div class="mt-3"><div class="d-flex align-items-center text-secondary"><span>Share to<!-- --></span><button aria-label="twitter" class="react-share__ShareButton shareBtn_lEr0" style="background-color:transparent;border:none;padding:0;font:inherit;color:inherit;cursor:pointer"><i class="br bi-twitter" style="font-size:16px"></i></button><button title="How to Access Answer Using HTTPS" aria-label="facebook" class="react-share__ShareButton shareBtn_lEr0" style="background-color:transparent;border:none;padding:0;font:inherit;color:inherit;cursor:pointer"><i class="br bi-facebook" style="font-size:16px"></i></button><button aria-label="linkedin" class="react-share__ShareButton shareBtn_lEr0" style="background-color:transparent;border:none;padding:0;font:inherit;color:inherit;cursor:pointer"><i class="br bi-linkedin" style="font-size:16px"></i></button></div><div class="mt-4"><a href="https://github.com/apache/answer-website/edit/main/blog/deploy-answer-https/index.md" target="_blank" rel="noopener noreferrer" class="theme-edit-this-page"><svg fill="currentColor" height="20" width="20" viewBox="0 0 40 40" class="iconEdit_N_05" aria-hidden="true"><g><path d="m34.5 11.7l-3 3.1-6.3-6.3 3.1-3q0.5-0.5 1.2-0.5t1.1 0.5l3.9 3.9q0.5 0.4 0.5 1.1t-0.5 1.2z m-29.5 17.1l18.4-18.5 6.3 6.3-18.4 18.4h-6.3v-6.2z"></path></g></svg>Edit this page<!-- --></a></div></div></article></div><div class="col-lg-2 col-md-12"><div class="tableOfContents_PDf4 thin-scrollbar"><ul class="border-0 p-0 table-of-contents table-of-contents__left-border"><li class="m-0 mb-2"><a href="#background" class="fs-14 text-secondary table-of-contents__link toc-highlight">Background</a></li><li class="m-0 mb-2"><a href="#easy-way" class="fs-14 text-secondary table-of-contents__link toc-highlight">Easy way</a></li><li class="m-0 mb-2"><a href="#preparation" class="fs-14 text-secondary table-of-contents__link toc-highlight">Preparation</a></li><li class="m-0 mb-2"><a href="#deploy" class="fs-14 text-secondary table-of-contents__link toc-highlight">Deploy</a><ul class="border-0 p-0 ps-3 mt-2"><li class="m-0 mb-2"><a href="#step-1" class="fs-14 text-secondary table-of-contents__link toc-highlight">Step 1</a></li><li class="m-0 mb-2"><a href="#step-2" class="fs-14 text-secondary table-of-contents__link toc-highlight">Step 2</a></li><li class="m-0 mb-2"><a href="#step-3" class="fs-14 text-secondary table-of-contents__link toc-highlight">Step 3</a></li></ul></li><li class="m-0 mb-2"><a href="#advanced" class="fs-14 text-secondary table-of-contents__link toc-highlight">Advanced</a></li></ul></div></div></div></div></div><footer class="footer"><div class="container py-3"><div class="d-flex justify-content-between flex-wrap text-center"><div><div class="mb-3"><a href="https://www.apache.org/" target="_blank"><svg id="Layer_1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 525" role="img" style="width:120px"><defs><style>.cls-1{fill:#7c297d}.cls-3{fill:#dd552c}.cls-4{fill:#d22128}</style></defs><path class="cls-1" d="M458.804 181.745h49.045l87.413 220.094h-53.455l-14.777-38.044h-87.406l-15.094 38.044H371.39l87.413-220.094Zm55.65 142.746L483.33 244l-30.814 80.491h61.938ZM622.717 331.722h48.735c.317 21.066 16.037 33.332 40.246 33.332 20.75 0 33.958-8.49 33.958-23.267 0-15.41-14.151-24.526-45.275-31.447-51.57-10.69-76.096-32.066-76.096-68.226 0-39.93 31.757-64.771 82.384-64.771 52.19 0 85.521 28.296 85.521 72.628h-48.11c0-19.806-13.834-31.756-36.785-31.756-21.065 0-33.958 8.806-33.958 23.267 0 13.525 11.634 22.014 45.275 29.871 54.714 12.892 77.665 33.642 77.665 68.542 0 41.505-32.073 66.347-84.262 66.347-55.34 0-89.298-28.929-89.298-74.52ZM852.91 181.745h137.716v45.276h-87.722v55.023h79.859v44.023h-79.86v75.772H852.91V181.745Z"></path><path class="cls-3" d="M141.108 209.888c13.187-32.608 27.9-65.152 43.688-93.997-23.567-17.504-46.196-55.249-55.493-71.972-3.34 3.794-5.508 8.163-6.49 11.718-8.76 31.625 22.42 69.814-2.693 55.861C99.195 99.871 52.08 74.41 34.107 99.717c20.128 25.862 72.773 90.93 107 110.171Z"></path><path d="M184.796 115.891c15.297-27.95 31.6-52.428 48.501-70.063 0 0-16.858 24.4-40.936 73.18 14.582 4.016 56.113 12.256 113.96-2.686 1.422-10.513-5.645-22.075-40.863-25.947-22.993-2.524 27.597-54.902-9.052-79.674a46.281 46.281 0 0 0-3.486-2.14 45.29 45.29 0 0 0-3.911-1.205c-42.803-11.17-48.736 61.409-65.816 45.806-27.6-25.212-45.022-19.321-53.89-9.243 9.297 16.723 31.926 54.468 55.493 71.972Z" style="fill:#f79a23"></path><path class="cls-4" d="M106.682 303.838c9.662-28.946 21.286-61.466 34.426-93.95-34.228-19.241-86.873-84.31-107-110.171-3.594 5.056-6.05 12.108-6.868 21.752-4.39 51.802 49.052 90.153 38.398 97.158-14.092 9.267-42.141-22.26-53.196-2.229 16.023 20.584 48.662 57.777 94.24 87.44Z"></path><path class="cls-3" d="M254.756 192.118c-27.059-9.65 28.276-35.533 46.245-62.991 2.3-3.511 4.676-8.049 5.32-12.805-57.847 14.942-99.378 6.702-113.96 2.686-12.465 25.257-26.859 57.084-41.87 95.458 15.634 6.685 79.47 31.38 169.637 31.507 15.16-39.485-39.691-44.699-65.372-53.855Z"></path><path class="cls-4" d="M117.137 309.049c15.9 4.955 68.584 19.756 124.537 17.528 7.517-20.352-20.586-22.338-22.875-38.661-1.772-12.63 73.957 10.614 98.323-35.311a59.485 59.485 0 0 0 3.006-6.632c-90.167-.127-154.003-24.822-169.637-31.507-10.97 28.044-22.256 59.517-33.354 94.583Z"></path><path class="cls-1" d="M117.137 309.049c-7.145 22.57-14.193 46.682-21.035 72.164a1771.75 1771.75 0 0 0-7.19 27.643c53.106 17.531 102.008.04 103.666-21.638.014-.172-.018-.3-.008-.464 1.264-22.961-33.15-10.234-32.336-24.038.818-13.906 60.081-.081 78.409-29.895a34.139 34.139 0 0 0 3.03-6.244c-55.952 2.228-108.636-12.573-124.536-17.528ZM12.442 216.398c-.774 1.404-1.472 3.026-2.068 4.965-10.292 33.45 62.485 78.385 52.583 88.18-8.925 8.827-20.557-11.343-34.9-3.012a22.05 22.05 0 0 0-4.806 3.75c-16.221 16.619-.254 64.496 45.77 90.052-10.74 36.062-21.432 76.351-31.9 118.486 3.798-1.33 8.342-2.663 9.473-6.245 1.698-6.981 12.194-49.462 29.235-107.094 0 0 3.11-11.806 8.804-31.255a1996.422 1996.422 0 0 1 22.049-70.387c-45.578-29.663-78.217-66.856-94.24-87.44ZM404.167 144.735h9.264v-62.2h23.348v-9.062h-55.96v9.062h23.348v62.2zM464.853 112.958h36.469v31.777h9.358V73.473h-9.358v30.417h-36.47V73.473h-9.256v71.262h9.257v-31.777zM581.403 135.963h-35.17v-23.106h31.588v-8.772h-31.588V82.151h34.106v-8.678h-43.363v71.262h44.427v-8.772z"></path></svg></a></div><div class="fs-14"><div class="my-3"><span>Copyright © 2023 - <!-- -->2025<!-- --> The Apache Software Foundation, Licensed under the Apache License, Version 2.0.<!-- --></span><br><span>Apache, Apache Answer, the Apache logo and the Apache Answer logo are either registered trademarks or trademarks of the Apache Software Foundation in the United States and/or other countries.</span></div><span>Feature icons by <!-- --> <!-- --><a href="https://www.flaticon.com" class="link-secondary" target="_blank">Freepik</a>.<!-- --></span></div></div></div></div></footer></div> |
| </body> |
| </html> |