Score:0

Nginx reverse-proxy pass front-end application matching url from HTTPS to HTTP

bd flag

I everyone. I'm very new to Nginx. My situation is like this. I have a Php application which that handles both backend and front-end, and also I have another ReactJs application as a micro-frontend service. I'm using a Docker container for the Nginx service.

Currently, domains are like this; Php application - https://my.happy.customers.local ReactJs - http://my.happy.customers.profile.local

What I want to achieve here is, whenever customers when to https://my.happy.customers.local/user/1234567989/profile url I want to send users to http:///my.happy.customers.profile.local:3001/user/1234567989/profile url.

All the cookies and local-storage values are bound to the https://my.happy.customers.local domain, so I want to use them from the second domain too.

How can I do this??

I managed to redirect url but in that way, I'm losing all cookies.

location ~ ^/(user)(/.*)(/profile)(/.*) {
  rewrite ^/(user)(/.*)(/profile)(/.*)$ http:///my.happy.customers.profile.local:3001$request_uri redirect
}

If I can redirect the user to the micro-frontend without changing the url, it will be great. Is this possible?

I tried this way but it's giving me an error.

location ~ ^/(user)(/.*)(/profile)(/.*) {
      resolver my.happy.customers.profile.local;
      proxy_pass http://my.happy.customers.profile.local:3001$request_uri
    }
Score:0
us flag

Your second example is the correct approach. However, there are issues in your example:

You have typed localtion, it should be location.

For the resolver directive, you need to specify either the domain name or IP address/addresses of the name servers you want nginx to use to resolve domain names. I doubt you have installed a recursive DNS resolver to my.happy.customers.profile.local server.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.