# Perspective behind nginx proxy generates "undefined" url when try to login

**URL:** <https://forum.inductiveautomation.com/t/perspective-behind-nginx-proxy-generates-undefined-url-when-try-to-login/84253>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [January 14, 2024, 12:16pm UTC](https://forum.inductiveautomation.com/t/perspective-behind-nginx-proxy-generates-undefined-url-when-try-to-login/84253 "2024-01-14T12:16:38Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![strinidad](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/strinidad/32/10275_2.png) [@strinidad](https://forum.inductiveautomation.com/u/strinidad)\
**Post date:** [January 14, 2024, 12:16pm UTC](https://forum.inductiveautomation.com/t/perspective-behind-nginx-proxy-generates-undefined-url-when-try-to-login/84253/1 "2024-01-14T12:16:38Z")

</div>

Hello,

I have many Perspective projects running on a local server. I'm triying to use a Nginx reverse proxy to use different domains.

For example I want to use:

- [https://myproject1.com](https://myproject1.com) and it must be proxied to [http://local-ignition:8088/data/perspective/client/project1](http://local-ignition:8088/data/perspective/client/project1)
- [https://myproject2.com](https://myproject2.com) and it must be proxied to [http://local-ignition:8088/data/perspective/client/project2](http://local-ignition:8088/data/perspective/client/project2)

And so on...

I configured nginx using the manual page.  
[https://docs.inductiveautomation.com/display/DOC81/Defining+SSL+on+a+Perspective+Reverse+Proxy](https://docs.inductiveautomation.com/display/DOC81/Defining+SSL+on+a+Perspective+Reverse+Proxy)

Also this thread has some caveats:

> [Reverse-proxy/rewrite for Perspective with Nginx, stuck on "Authenticating..."](https://forum.inductiveautomation.com/t/reverse-proxy-rewrite-for-perspective-with-nginx-stuck-on-authenticating/31716)

And finally, another thread has the same problem:

> [Perspective Login Button 404 Error](https://forum.inductiveautomation.com/t/perspective-login-button-404-error/65710)

If I access to https::/myproject1.com I get the login page like this:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/b/5bb89f019f4a963b3cc8ba64d95e61ca9b86079c.jpeg)

But as soon I click the button I get this:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/6/3638449df12e2b0bda954d570cda62b6f4f92eb9.png)

The nginx error logs shows nothing, but access log shows this:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/a/fa99101da033d0dc5ef432384234f3bcc76bc99e.png)

As I can see, is that the button redirects to an url not defined "undefined" but after this, the gateway serves a css from the "res" subfolder. Then this give the information that some parts of the proxy are working correct.

My nginx configuration is this:

> **/etc/nginx/sites-enabled/myproject1.com**
>
> ```auto
> server {
> listen 443 ssl;
> listen [::]:443 ssl;
> include /etc/nginx/perspective_params;
> include /etc/nginx/proxy_params;
> server_name myproject1.com;
> underscores_in_headers on;
> 
> # The next few location contexts define how to process resources required by the Perspective session.
> # If the longest matching prefix location has the “^~” modifier then regular expressions are not checked.
> location ^~ /data/ {
> proxy_pass http://192.168.1.123:8088/data/;
> include /etc/nginx/perspective_params;
> include /etc/nginx/perspective_location_params;
> }
>  
> location ^~ /system/ {
> proxy_pass http://192.168.1.123:8088/system/;
> include /etc/nginx/perspective_params;
> include /etc/nginx/perspective_location_params;
> }
>  
> location ^~ /res/ {
> proxy_pass http://192.168.1.123:8088/res/;
> include /etc/nginx/perspective_params;
> include /etc/nginx/perspective_location_params;
> }
>  
> location ^~ /idp/ {
> proxy_pass http://192.168.1.123:8088/idp/;
> include /etc/nginx/perspective_params;
> include /etc/nginx/perspective_location_params;
> }
>  
> location ^~ /.well-known/ {
> proxy_pass http://192.168.1.123:8088/.well-known/;
> include /etc/nginx/perspective_params;
> include /etc/nginx/perspective_location_params;
> }   
>  
> # Here we are setting the protocol type, address, port, and uri (optional) that will be the destination of our proxied server:
> location / {
> proxy_pass http://192.168.1.123:8088/data/perspective/client/project1/;
> include /etc/nginx/perspective_params;
> include /etc/nginx/perspective_location_params;
> }
> ssl_certificate /etc/letsencrypt/live/myproject1.com/fullchain.pem; # managed by Certbot
> ssl_certificate_key /etc/letsencrypt/live/myproject1.com/privkey.pem; # managed by Certbot
> 
> }
> 
> server {
> if ($host = myproject1.com) {
> return 301 https://$host$request_uri;
> } # managed by Certbot
> 
> listen 80;
> server_name myproject1.com;
> }
> 
> ```

> **/etc/nginx/perspective\_params**
>
> ```auto
> proxy_http_version 1.1;                    
> proxy_set_header Upgrade $http_upgrade;        
> proxy_set_header Connection "upgrade";         
> 
> ```

> **/etc/nginx/perspective\_location\_params**
>
> ```auto
> proxy_set_header Host $host;
> proxy_pass_request_headers on;
> proxy_cache_bypass $http_upgrade;
> 
> ```

> **/etc/nginx/proxy\_params**
>
> ```auto
> proxy_set_header Host $http_host;
> proxy_set_header X-Real-IP $remote_addr;
> proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
> proxy_set_header X-Forwarded-Proto $scheme;
> proxy_intercept_errors on;
> 
> ```

Anyone can help me.

Regards

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 14, 2024, 1:24pm UTC](https://forum.inductiveautomation.com/t/perspective-behind-nginx-proxy-generates-undefined-url-when-try-to-login/84253/2 "2024-01-14T13:24:59Z")

</div>

You're going to struggle with the fact that Perspective accesses a lot of resources that aren't project specific, but browsers expect to be in the same domain. I'll be shocked if you get separate domains per project to work.

---

<div class="post-metadata">

**Author:** ![strinidad](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/strinidad/32/10275_2.png) [@strinidad](https://forum.inductiveautomation.com/u/strinidad)\
**Post date:** [January 14, 2024, 1:56pm UTC](https://forum.inductiveautomation.com/t/perspective-behind-nginx-proxy-generates-undefined-url-when-try-to-login/84253/3 "2024-01-14T13:56:38Z")

</div>

Sorry but my english is not as good as i wanted,  
then are you saying that it will be hard to acomplish or it will be imposible ?

Maybe changing referers or any parameter in the headers.

I have this solution working but with vision and the web module and subdomains.

Thanks.

---

<div class="post-metadata">

**Author:** ![michael.flagler](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/michael.flagler/32/26272_2.png) [@michael.flagler](https://forum.inductiveautomation.com/u/michael.flagler)\
**Post date:** [January 14, 2024, 2:46pm UTC](https://forum.inductiveautomation.com/t/perspective-behind-nginx-proxy-generates-undefined-url-when-try-to-login/84253/4 "2024-01-14T14:46:15Z")

</div>

Not familiar with using Nginx as a reverse proxy, but I would think it would be possible. I personally use HAProxy, but the way I do it is the subdomains ([abc.servername.com](http://abc.servername.com), [xyz.servername.com](http://xyz.servername.com), etc) all just redirect to the project URL on the parent server domain ([ignition.servername.com](http://ignition.servername.com)). So while they're not entirely masked from the end user knowing they're using a common server, this is how I've made it work. I don't think I've tried doing it any other way with HAProxy as I was just looking for an easy way for end users to hit the project while on the go.

---

<div class="post-metadata">

**Author:** ![Virgar\_Poulsen](https://avatars.discourse-cdn.com/v4/letter/v/ad7895/32.png) [@Virgar\_Poulsen](https://forum.inductiveautomation.com/u/Virgar_Poulsen)\
**Post date:** [March 7, 2024, 1:59pm UTC](https://forum.inductiveautomation.com/t/perspective-behind-nginx-proxy-generates-undefined-url-when-try-to-login/84253/5 "2024-03-07T13:59:08Z")

</div>

How did you get this to work with subdomains ?

---

<div class="post-metadata">

**Author:** ![strinidad](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/strinidad/32/10275_2.png) [@strinidad](https://forum.inductiveautomation.com/u/strinidad)\
**Post date:** [April 24, 2024, 9:24pm UTC](https://forum.inductiveautomation.com/t/perspective-behind-nginx-proxy-generates-undefined-url-when-try-to-login/84253/6 "2024-04-24T21:24:52Z")

</div>

Hello,

I'm trying to use subdomains, now i have:  
`https://project1.example.com`  
`https://project2.example.com`

But the same result.

If i use nginx rewrite directive:  
`rewrite ^ /data/perspective/client/project1 permanent;`

i can access project, but the url then changes from:  
`http://project1.example.com`  
to  
`http://project1.example.com/data/perspective/client/project1`

And that is what I want to hide to the client.

@pturmel @michael.flagler any ideas.

Regards

---

<div class="post-metadata">

**Author:** ![michael.flagler](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/michael.flagler/32/26272_2.png) [@michael.flagler](https://forum.inductiveautomation.com/u/michael.flagler)\
**Post date:** [April 24, 2024, 10:08pm UTC](https://forum.inductiveautomation.com/t/perspective-behind-nginx-proxy-generates-undefined-url-when-try-to-login/84253/7 "2024-04-24T22:08:54Z")

</div>

I don't use nginx, but I also don't think that's possible. The subdomains I use are for ease-of-use and don't involve rewrites to try to strip off the URL path. For example:

`https://site1.customerdomain.com`  
redirects to something like  
`https://scada.customerdomain.com/data/perspective/client/site1`

and

`https://site2.customerdomain.com`  
redirects to something like  
`https://scada.customerdomain.com/data/perspective/client/site2`

This just makes it easier for that customer to get to those different projects without having to remember the full path or going to the home page and clicking on the site they want. My Ignition server base subdomain name (in this case `scada` though is always different than the redirected subdomain (`site1` and `site2`).

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 24, 2024, 10:50pm UTC](https://forum.inductiveautomation.com/t/perspective-behind-nginx-proxy-generates-undefined-url-when-try-to-login/84253/8 "2024-04-24T22:50:57Z")

</div>

> [@strinidad](#):
>
> And that is what I want to hide to the client.

You cannot, as far as I know.

---

<div class="post-metadata">

**Author:** ![Guido\_Lorenzotti](https://avatars.discourse-cdn.com/v4/letter/g/919ad9/32.png) [@Guido\_Lorenzotti](https://forum.inductiveautomation.com/u/Guido_Lorenzotti)\
**Post date:** [September 20, 2024, 1:08pm UTC](https://forum.inductiveautomation.com/t/perspective-behind-nginx-proxy-generates-undefined-url-when-try-to-login/84253/9 "2024-09-20T13:08:22Z")

</div>

Hello Strinidad, can you resolve this issue?

I have the same problem. I can access successfully to the homepage, but when i press the login button nginx redirect me to /data/perspective/login/undefined.

---

<div class="post-metadata">

**Author:** ![strinidad](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/strinidad/32/10275_2.png) [@strinidad](https://forum.inductiveautomation.com/u/strinidad)\
**Post date:** [November 12, 2024, 11:13am UTC](https://forum.inductiveautomation.com/t/perspective-behind-nginx-proxy-generates-undefined-url-when-try-to-login/84253/10 "2024-11-12T11:13:52Z")

</div>

Hello Guido,

The "undefined" problem was solved when I changed from subpages to subdomains.  
I think was one redirect directive.

Now I'm using the approax of my post as I marked as solution.

Regards
