# /etc/nginx/sites-available/medusa, from https://exe.dev/deploy/medusa # # Port 8000 is the VM's public face (https://.exe.xyz/): the storefront # and the parts of Medusa that shoppers and webhooks need. The admin and the # admin API stay on port 9000, which exe.dev keeps private. map $http_x_forwarded_proto $medusa_proto { default $http_x_forwarded_proto; "" $scheme; } server { listen 8000; listen [::]:8000; server_name _; client_max_body_size 10m; proxy_http_version 1.1; proxy_set_header Host $http_host; proxy_set_header X-Forwarded-Proto $medusa_proto; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # Never on the public port: the admin, the admin API, admin sign-in. location ~ ^/(app|admin|auth/user)(/|$) { return 404; } # The Store API (carts, products, checkout), customer sign-in, # payment webhooks, and uploaded product images. location /store/ { proxy_pass http://127.0.0.1:9000; } location /auth/customer/ { proxy_pass http://127.0.0.1:9000; } location /hooks/ { proxy_pass http://127.0.0.1:9000; } location /static/ { proxy_pass http://127.0.0.1:9000; } # Everything else is the Next.js storefront. Next.js 16 builds its # rewrites and redirects from its own address (127.0.0.1:8001), and # breaks its own rewrites when told the request came over https; so # don't tell it, and turn its absolute redirects into relative ones. location / { proxy_pass http://127.0.0.1:8001; proxy_set_header X-Forwarded-Proto ""; proxy_redirect http://127.0.0.1:8001/ /; } }