How to host a Shopify export on Nginx
To host a Shopify storefront export on Nginx, copy the unzipped folder to your web root and add a server block. The copy is static, so it has no cart or checkout. Use exact match location blocks with return 302 to send /cart, /checkout and /account to your Shopify store, and re-export when prices change.
Last reviewed
Key facts
- An exact match location (=) is checked first and ends the search immediately.
- return with a URL sends a redirect, and 302 is the default code.
- The request URI variable keeps the rest of the path and any query string.
- Static pages hold prices from the day of the export.
What a Shopify export brings to Nginx
WebExport saves a Shopify storefront as static pages, product layouts, collection pages, fonts and images. Nginx serves the files and answers fast, since there is no application behind them. That works for a catalog, an archive or the front pages of a store whose checkout stays on Shopify.
Nginx matches locations in a fixed order. An exact match wins over a prefix, and a prefix marked with ^~ wins over regular expressions. Use that to keep the three Shopify paths in their own small blocks and leave everything else to the default location.
Copy the files and add a server block
- Copy the unzipped folder to the web root on your server, for example /var/www/exported-site.
- Add a server block that points root at that folder and lists index.html as the index file.
- Check the syntax, then reload Nginx without dropping connections.
- Request a certificate for the domain once DNS points at the server.
rsync -av --delete exported-site/ user@server:/var/www/exported-site/
sudo nginx -t && sudo systemctl reload nginxRedirects, headers and 404s on Nginx
Nginx keeps everything in its own config files. Use return 301 for a single move and a map block for a table of old and new paths. error_page 404 /404.html picks the not-found file, and try_files decides how URLs map to files. An add_header directive set inside a location block replaces the ones inherited from the server level, so repeat the headers you still want there. Nginx ignores .htaccess files, which only Apache reads.
Add these blocks above the main location. Each sends a server-only path to the Shopify store.
server {
listen 80;
server_name example.com;
root /var/www/exported-site;
index index.html;
location = /cart { return 302 https://your-store.myshopify.com/cart; }
location = /checkout { return 302 https://your-store.myshopify.com/checkout; }
location ^~ /account { return 302 https://your-store.myshopify.com$request_uri; }
error_page 404 /404.html;
location / {
try_files $uri $uri.html $uri/ =404;
}
}Replace your-store with your own myshopify.com handle. $request_uri carries the whole path and query, so /account/login goes to the same path on Shopify. Use 302 while you test, then change to 301 only if the destination will never change. Check with curl -I that each path answers with the right Location header.
Shopify output that needs fixing on Nginx
| In the Shopify output | What to do on any static host |
|---|---|
| /cart and /checkout paths | These are server pages. The static copy has no cart, so link buyers to your Shopify checkout or a buy button. |
| Calls to /cart.js and product .js endpoints | These live Shopify endpoints return 404 on a static host. Remove or replace the scripts that call them. |
| Prices and stock frozen at export time | Product pages show the values from the day of the export. Re-export after price changes. |
| Images from cdn.shopify.com | Rewritten to local paths. Check large collection pages, because product images add up quickly. |
Find theme scripts that call /cart.js, /cart/add.js or product .js endpoints. Those belong to Shopify and return 404 from Nginx, so add to cart breaks. Replace the button with a link to the product on your store. Rebuild contact forms against a service you use. Re-export after each price update, because the pages never refresh on their own.
Forms and dynamic features
Nginx can proxy a POST to another service with proxy_pass but cannot process a form itself. Send the form to a form service or to an app you run on the same server.
Nginx can proxy a form POST with proxy_pass, but it will not store it. Point the form at a service or at an app you run on the same machine.
What can go wrong
- Redirecting with 301 too early caches a wrong destination in browsers. Use 302 until you are sure.
- Without a certificate, shoppers see warnings before they reach the Shopify redirect.
- Old prices on saved pages can lead to disputes. Re-export on a fixed schedule.
Frequently asked questions
Can Nginx run a Shopify checkout?
No. Checkout runs on Shopify. Redirect the cart and checkout paths to the store and let Nginx serve the browsing pages.
Why use an exact location for /cart?
The = modifier ends the search as soon as it matches, so nothing else can capture the path. It also keeps the rule from touching other URLs that begin with the same letters.
How do I keep query strings when redirecting?
Use $request_uri in the destination URL, which carries the original path and the query string, so a visitor who followed a link with arguments arrives with them intact.
Will my product URLs change?
No. Product and collection paths keep their original addresses in the saved copy, so existing links and search results keep working on the same domain.
Official documentation
Free tools for this job
- No-Code Platform DetectorInstantly detect if a site is built with Webflow, Framer, Squarespace, Wix, or Shopify.
- Website Asset Size AnalyzerAnalyze all images, JS, and CSS weights to find performance bottlenecks.
- Static Hosting PickerAnswer 5 questions and get the best hosting recommendation for your exported site.
- HTTP Header SEO InspectorInspect SEO-relevant HTTP headers for URL lists in bulk.
Get the Shopify files first
Paste your public Shopify URL into the export form and download a ZIP you can deploy to Nginx. The Free plan covers 1 site, 5 exports a month, 15 pages and 20 MB per export. Professional is a $9.99 one-time purchase with unlimited pages.