ติดตั้ง n8n in docker with https ngrok
Table of Contents
Introduction
This tutorial will guide you through the process of installing n8n in Docker and configuring it to run with HTTPS using ngrok. This setup allows you to use webhooks securely, providing a static domain for your n8n instance.
Step 1: Install Docker
Before you can use n8n and ngrok, ensure you have Docker installed on your machine. If you haven't installed Docker yet, follow these steps:
- Go to the Docker website.
- Download the installer for your operating system (Windows, macOS, or Linux).
- Follow the installation instructions provided.
Step 2: Set Up ngrok in Docker
To run ngrok in Docker, you'll need to execute a command in your terminal. Follow these steps:
-
Open your terminal.
-
Run the following command, replacing
AUTH-TOKEN
andDOMAIN-FROM-NGROK
with your ngrok auth token and desired domain:docker run -d \ --name ngrok-https \ -e NGROK_AUTHTOKEN=AUTH-TOKEN \ ngrok/ngrok:latest \ http --domain=DOMAIN-FROM-NGROK host.docker.internal:5678
- Change
ngrok-https
to a name of your choice for the ngrok container. - The
NGROK_AUTHTOKEN
value is obtained from your ngrok account. - The
DOMAIN-FROM-NGROK
should be the static domain you receive from ngrok.
- Change
Step 3: Configure Environment Variables for n8n
Next, you need to set up the necessary environment variables for n8n. These variables ensure that n8n operates correctly with ngrok.
-
Create a
.env
file for your n8n setup if you haven't already. -
Add the following lines to your
.env
file, replacingNGROK-DOMAIN
with your ngrok static domain:N8N_COMMUNITY_PACKAGES_ALLOW_TOOL_USAGE=true N8N_EDITOR_BASE_URL=https://NGROK-DOMAIN WEBHOOK_URL=https://NGROK-DOMAIN N8N_DEFAULT_BINARY_DATA_MODE=filesystem N8N_RUNNERS_ENABLED=true N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true
Step 4: Run n8n in Docker
Now, you can run n8n itself using Docker:
-
Use the following command to start n8n:
docker run -d \ --name n8n \ -p 5678:5678 \ --env-file .env \ n8n
- This command will run n8n on port 5678.
Step 5: Access n8n
After running the containers, you can access your n8n instance:
- Open your web browser.
- Navigate to
https://NGROK-DOMAIN
, whereNGROK-DOMAIN
is the domain you set up with ngrok.
Conclusion
You have successfully set up n8n in Docker with HTTPS using ngrok. This configuration allows you to securely use webhooks with a static domain.
Next Steps
- Explore n8n's features and capabilities to automate workflows.
- Review ngrok documentation for advanced configurations and troubleshooting.
- Consider using a custom domain for production use instead of the ngrok domain for better branding and reliability.