Excluded Files per Server

New Features, Tips & Tricks, and Tutorials

Excluded Files per Server

When deploying a project with DeployHQ, you can exclude files and directories from being uploaded. But what happens when different servers need different files? Your production server might not need test fixtures, your staging server might need a debug config that production shouldn't have, and your static asset server doesn't need backend code at all.

With per-server exclusion rules, you can define exactly which files reach each deployment target.

How it works

DeployHQ lets you set exclusion rules at two levels:

flowchart TD
    A[Repository] --> B{Project-Level Exclusions}
    B --> C[Files filtered for ALL servers]
    C --> D{Per-Server Exclusions}
    D --> E[Production Server<br/>Additional rules applied]
    D --> F[Staging Server<br/>Different rules applied]
    D --> G[Asset Server<br/>Its own rules applied]
  • Project-level exclusions apply to every server in the project (configured in Settings → Excluded Files, or via .deployignore)
  • Per-server exclusions apply only to a specific server, on top of the project-level rules

When you add an exclusion rule through the UI, you'll see an option: Exclude this file on all current and future servers?. Uncheck this to make the rule apply only to the server you're currently editing.

Common use cases

Different configs per environment

Your production server shouldn't receive development or testing configuration:

File Production Staging Dev
.env.production ✅ Deploy ❌ Exclude ❌ Exclude
.env.staging ❌ Exclude ✅ Deploy ❌ Exclude
.env.development ❌ Exclude ❌ Exclude ✅ Deploy
debug.config.php ❌ Exclude ✅ Deploy ✅ Deploy

Backend vs frontend servers

If you deploy the same repository to separate backend and frontend servers:

Frontend server exclusions:

app/controllers/**
app/models/**
database/**
config/database.yml
Procfile

Backend server exclusions:

public/assets/**
public/images/**
node_modules/**
webpack.config.js
package.json

Static asset server

A CDN origin or static file server only needs compiled assets:

app/**
config/**
database/**
tests/**
vendor/**
*.php
*.rb
*.py
Gemfile
Gemfile.lock
composer.json
composer.lock

Setting up per-server exclusions

  1. Navigate to your project in DeployHQ
  2. Go to Settings → Excluded Files
  3. Click Add a New Exclusion Rule
  4. Enter your file pattern (e.g. config/database.yml)
  5. Uncheck Exclude this file on all current and future servers?
  6. Select the specific server(s) this rule should apply to
  7. Click Save

The same pattern syntax applies as regular exclusions — wildcards (*, **), directory matching, and whitelisting with ! all work.

Per-server vs .deployignore

One important distinction: the .deployignore file applies to all servers in a project. If you need server-specific rules, you must use the Excluded Files UI.

A common approach is to combine both:

Method Scope Version controlled
.deployignore All servers Yes — in your repository
Project-level UI exclusions All servers No — in DeployHQ settings
Per-server UI exclusions Specific servers only No — in DeployHQ settings

Use .deployignore for universal rules (like excluding node_modules or tests), and per-server exclusions for environment-specific files.

Verifying your rules

After a deployment, check the log under the Generate Manifest step. DeployHQ shows excluded files per server, so you can confirm each server received the right set of files.

For the full documentation, see our support article on excluded files.


Ready to streamline your multi-server deployments? Sign up for DeployHQ and get started in minutes. If you have any questions, reach out to us at support@deployhq.com or on Twitter/X @deployhq.