feat: customize port number
Hi, I am a back-end developer at a Korean startup. While deploying an application web server as a Docker container on a self-hosted Ubuntu server, I integrated Coolify for its CI/CD. However, I found it inconvenient that the port for Coolify was fixed at 8000. Since this is my first contribution, it might not be perfect, but I wanted to improve this aspect and suggest a feature to customize the port when installing Coolify on self hosted servers.
Submit Checklist (REMOVE THIS SECTION BEFORE SUBMITTING)
- [x] I have selected the
nextbranch as the destination for my PR, notmain. - [x] I have listed all changes in the
Changessection. - [ ] I have filled out the
Issuessection with the issue/discussion link(s) (if applicable). - [ ] I have tested my changes.
- [x] I have considered backwards compatibility.
- [ ] I have removed this checklist and any unused sections.
Changes
This PR adds support for specifying a custom port number when installing Coolify on a self-hosted server. The following changes have been made:
- Modified the installation script (
install.sh) to allow specifying a custom port using the--port (-p)option instead of the default 8000 if needed. - Updated .env.production file generation to include the
APP_PORTkey, so that .env file'sAPP_PORTcan have the provided custom port number or falling back to 8000 if not specified. - Modified
upgrade.shto reference theAPP_PORTvalue from the .env file, ensuring that the Coolify Docker container runs on the specified port. - Updated the documentation to guide users on installing Coolify with a custom port using:
curl -fsSL https://cdn.coollabs.io/coolify/install.sh | sudo bash -s -- --port {{PORT_NUM}}
Let me know if there's anything that needs improvement!
Issues
- fix #
fyi you can also do this by creating this file here /data/coolify/source/docker-compose.custom.yml
with the contents:
services:
coolify:
ports: !override
- "1234:8080"
this is useful if you need to remove ports altogether if on cloudflared etc, you can just use ports: !reset []
@coderabbitai review
📝 Walkthrough
Summary by CodeRabbit
-
New Features
- Enabled custom port configuration during installation and upgrade, allowing users to specify a port number other than the default.
- Updated application messages to reflect the dynamically set port during runtime.
-
Documentation
- Enhanced setup instructions with guidelines on how to use the new option for specifying a custom port.
Walkthrough
Listen up, meatbags. The update introduces a new environment variable, APP_PORT, into the production environment file, positioning it between APP_KEY and DB_USERNAME without disturbing the existing order. The README now explains how to customize the port for the Coolify application using a new --port option. Meanwhile, the installation script (scripts/install.sh) now accepts custom port parameters (-p or --port), validating inputs and updating generated .env files and output messages accordingly. The upgrade script (scripts/upgrade.sh) retrieves the new port setting from the environment file, defaulting to 8000 if not specified. Now, get out there and enjoy these changes—preferably with a taco in hand.
Changes
| File(s) | Change Summary |
|---|---|
.env.production |
Added APP_PORT between APP_KEY and DB_USERNAME without modifying existing variables. |
README.md |
Updated installation instructions to include a --port option for customizing the application port instead of using the default 8000. |
scripts/install.sh |
Introduced a new PORT variable with default value 8000, added -p/--port options for custom port input, validated numeric input, and modified the generation of the .env file to include APP_PORT. Also updated output messages with the dynamic port value. |
scripts/upgrade.sh |
Added logic to retrieve APP_PORT from the /data/coolify/source/ .env file, setting PORT to its value or defaulting to 8000 if not set, before running configuration downloads. |
Sequence Diagram(s)
sequenceDiagram
participant U as User
participant I as install.sh
participant ENV as .env Generator
participant Msg as Output Messages
U->>I: Invoke install.sh [-p PORT]
I->>I: Parse options (-p/--port) and validate input
alt Valid Port Specified?
I->>I: Set PORT to provided value
else
I->>I: Default PORT to 8000
end
I->>ENV: Generate .env file with APP_PORT
ENV-->>I: .env file created
I->>Msg: Update output messages with dynamic PORT
Msg-->>U: Display updated access URLs
sequenceDiagram
participant U as User
participant UPG as upgrade.sh
participant ENV as .env Reader
U->>UPG: Invoke upgrade.sh
UPG->>ENV: Read APP_PORT from /data/coolify/source/.env
alt APP_PORT exists?
ENV-->>UPG: Return APP_PORT value
else
UPG->>UPG: Default PORT to 8000
end
UPG->>U: Proceed with configuration downloads using PORT
✨ Finishing Touches
- [ ] 🔥 Error while generating docstrings. (🔄 Check again to generate again)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
‼️ IMPORTANT Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai generate unit testing code for this file.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read src/utils.ts and generate unit testing code.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.@coderabbitai help me debug CodeRabbit configuration file.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (Invoked using PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai planto trigger planning for file edits and PR creation.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
I was kinda surprised to find that so many ports were open - given that it sets up Traefik proxy, why does port 6001, 6002, 8000 and 8080 have to be exposed at all? The containers communicate on the Docker network so is there any reason for these to be exposed?
I disabled them and haven't noticed any issues so far:
`/data/coolify/source/docker-compose.custom.yml':
services:
coolify:
ports: !reset []
expose: !reset []
soketi:
ports: !reset []
(thanks @djsisson for hint on how to reset!)
/data/coolify/proxy/docker-compose.yml:
Comment out port 8080:
ports:
- '80:80'
- '443:443'
- '443:443/udp'
# - '8080:8080'
It was a mistake, sorry. I recreated the next branch and it auto-closed this PR.
@colinmollenhour these ports are there for cases when the Traefik proxy might go down, so people can continue to access Coolify and use all its features easily. Port 8000 is being used by the Coolify Dashboard and 6001 + 6002 are then needed for communication with the realtime service via websocket connections. (I can't remember from the top of my head what 8080 was for again).
@Cinzya 8080 is for traefik dashboard
all 3 ports are only required when the proxy is down (6001, 6002, 8000) so having them open all the time is not required
if the proxy goes down, you can always manually restart it, so outside of inital installation imo, they can be closed
a different solution would be to have a bootstrap nginx in the compose, which you can start/stop to open close those ports during installation / no proxy / restoration etc
i.e if coolify detects the proxy is not running, it would start the nginx container so be accessible on 8000, then when proxy is running it owuld stop it again, thus minimizing the amount of open ports
the reason for wanting to close them is, it is very easy to restrict access to domains externally using say cloudflare or traefik failtoban plugins. but you can't when there is a direct connection to the container always open.
Opening ports unnecessarily is bad security practice. If anything, they could just be opened on the localhost:
ports:
- '80:80'
- '443:443'
- '443:443/udp'
- '127.0.0.1:8080:8080'
This way you can easily access it from within a remote SSH session or using a temporary http tunnel like ngrok, but it's not exposed to the public 24/7.