thank-you page not redirecting to the actual domain when using NGINX as a reverse proxy

5 0 1

I have set up NGINX on Heroku's infrastructure to manage domain mapping for my store, bypassing Shopify's built-in domain configuration.

Here's an overview of my NGINX configuration:


upstream app_server {
	server unix:/tmp/nginx.socket fail_timeout=0;

server {
	listen <%= ENV["PORT"] %>;
	server_name _;
	keepalive_timeout 5;
	port_in_redirect off;

	location / {

		client_max_body_size    10m;
		client_body_buffer_size     128k;
		proxy_connect_timeout 90;

		# proxy_set_header Host $host;
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

	location ~ ^/(search|category)/? {
		proxy_pass http://app_server;
		proxy_redirect off;

		proxy_set_header   Host             $host;
		proxy_set_header   X-Real-IP        $remote_addr;
		proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;


I've configured NGINX to handle incoming requests in a specific way. Requests to search and category pages are directed to a separate backend setup, while all other pages are intended to be served by Shopify itself.


I have successfully managed the entire flow, from adding items to the cart to reaching the checkout process, using my custom domain.

However, I encountered an issue with Shopify's automatic redirection to the thank you page. Instead of using my custom domain, Shopify redirects to a thank you page with their generated store name that includes the 'myshopify' domain. The page displayed is not valid.


Interestingly, if I manually change the 'myshopify' domain to our custom domain in the URL and refresh the page, it loads the proper thank you page as desired. I've spent several days experimenting with different configurations, but I haven't found a solution.


I would greatly appreciate it if someone could provide guidance on resolving this issue.


Replies 0 (0)