Skip to content

caged/nginx-test

Repository files navigation

Running

Edit your /etc/hosts file and add

127.0.0.1	nginx-test.local
127.0.0.1	admin.nginx-test.local
docker-compose up

About

How to use an nginx reverse proxy to serve a subdirectory in nextjs through a subdomain. For example, if you have a pages directory that is structured

pages/
  - index.js
  - about.js
  - admin/
      - index.js
      - dashboard.js

Typically, you would access the admin pages as http://host/admin and http://host/admin/dashboard, however if you use nginx reverse proxy, you can use a subdomain to mask the admin folder.

It's important to note that you must set the assetPrefix in next.config.js to the host root when doing this.

About

example on how to serve nextjs subdirectories using a subdomain and nginx reverse proxy

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published