How to Access Answer Using HTTPS
Background
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?
Some questions:
...
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.
Easy way
This blog aims to introduce the easiest way to deploy Answer with HTTPS. You can use Caddy 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.
Preparation
You can follow the installation guide to install Answer. After installing Answer, you can access it using HTTP. The default port for Answer is 9080. You can access it at http://localhost:9080. In the following steps, we will use 9080 as the default port for Answer.
You need a domain that DNS resolution is already configured to point to your server.
In this blog we will use docker-compose to install Caddy. So we need docker and docker-compose. You can follow the official guide to install docker and docker-compose.
Deploy
Step 1
$ mkdir caddy-docker
$ cd caddy-docker
$ vim docker-compose.yml
You can create a docker-compose.yml
file in the new directory, and then add the following code:
version: "3.7"
services:
caddy:
image: caddy
restart: unless-stopped
ports:
- "80:80"
- "443:443"
- "443:443/udp"
volumes:
- $PWD/Caddyfile:/etc/caddy/Caddyfile
- $PWD/caddy_data:/data
- $PWD/caddy_config:/config
network_mode: host
Step 2
The Caddyfile
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 /etc/caddy/Caddyfile
.
$ vim Caddyfile
Create Caddyfile
file in the same directory, and then add the following code:
your.answer.domain {
reverse_proxy 127.0.0.1:9080
}
Run the following command to start Caddy. Wait a few seconds, and then you can access Answer using HTTPS.
$ docker-compose up -d
If you can’t access it, you can check the logs of Caddy.
$ docker-compose logs
Advanced
If you don’t want to use network_mode: host
in docker-compose.yml
, 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:
your.answer.domain {
reverse_proxy answer-service:9080
}
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 Meta. We will try our best to help you.
Subscribe to my newsletter
Read articles from Apache Answer directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Apache Answer
Apache Answer
Unleash collective wisdom with Answer, an open-source Q&A platform software tool that every team needs. For free. As an Apache Incubator Project, we're dedicated to building a better product, a diverse community, and following the Apache Way. Contributions are always welcome, and you can learn more about us here: Visit Answer's official website: http://answer.apache.org/ GitHub: https://github.com/apache/incubator-answerhttps://hashnode.com/settings#