Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About access unstract web from other computer #414

Open
haluwong opened this issue Jun 21, 2024 · 18 comments
Open

About access unstract web from other computer #414

haluwong opened this issue Jun 21, 2024 · 18 comments
Assignees
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers question Further information is requested

Comments

@haluwong
Copy link

It seems the webUI can only access through http://frontend.unstract.localhost/ which point to 127.0.0.1

I'm trying to setup nginx to reverse proxy to it through another URL and set host header to frontend.unstract.localhost.
Can see the login screen but will redirect back to http://frontend.unstract.localhost/!!!

Is there anyway to setup with another hostname? Please advise?

Thanks,
Halu

@haluwong haluwong added the bug Something isn't working label Jun 21, 2024
@ritwik-g ritwik-g added question Further information is requested and removed bug Something isn't working labels Jun 21, 2024
@ritwik-g
Copy link
Contributor

ritwik-g commented Jun 21, 2024

Hi @haluwong ,
I think below can help you with setting it up for a different domain.

  1. You actually don't need to use nginx. We are using traefik already in our docker-compose. So you can continue using this. We just need to make changes to the hosts in routing rules and backend envs.
  2. To change routing rules you need to change the host name from frontend.unstract.localhost to which even hostname you want to use.
    - traefik.http.routers.backend.rule=Host(`frontend.unstract.localhost`) && PathPrefix(`/api/v1`, `/deployment`)
    - traefik.http.routers.frontend.rule=Host(`frontend.unstract.localhost`)
  3. Should change envs in backend related to the FE URL.
    DJANGO_APP_BACKEND_URL=http://frontend.unstract.localhost
    LOGIN_NEXT_URL="http://frontend.unstract.localhost/org"
    LANDING_URL="http://frontend.unstract.localhost/landing"
    ERROR_URL="http://frontend.unstract.localhost/error"
    WEB_APP_ORIGIN_URL="http://frontend.unstract.localhost"
    (In local should be changing the backend/.env file. If you are making change in backend/sample.env file then you need to delete the backend/.env file if it already exists and then run the script)

This should be enough to get it running for a different host.

Please try and let us know if it works for you.

Also if possible it would be great if you can help with a new README on how to setup unstract for different host.

@ritwik-g ritwik-g added documentation Improvements or additions to documentation good first issue Good for newcomers labels Jun 21, 2024
@dumbsheep1990
Copy link

I modified the corresponding points according to the prompts. The homepage can be accessed, but after logging in, it still jumps to http://frontend.unstract.localhost.

@dumbsheep1990
Copy link

I modified the host configuration in sample.proxy_overrides.yaml, but it still prompts that verification cannot be performed when logging in, and jumps back to the landing page.

@ritwik-g
Copy link
Contributor

@dumbsheep1990 Hi can you confirm if the changes where made in backend/sample.env as mentioned in the below thread. If you have could you please share the screenshots or share the configuration itself of backend?

Hi @haluwong , I think below can help you with setting it up for a different domain.

  1. You actually don't need to use nginx. We are using traefik already in our docker-compose. So you can continue using this. We just need to make changes to the hosts in routing rules and backend envs.
  2. To change routing rules you need to change the host name from frontend.unstract.localhost to which even hostname you want to use.
    - traefik.http.routers.backend.rule=Host(`frontend.unstract.localhost`) && PathPrefix(`/api/v1`, `/deployment`)

    - traefik.http.routers.frontend.rule=Host(`frontend.unstract.localhost`)
  3. Should change envs in backend related to the FE URL.
    DJANGO_APP_BACKEND_URL=http://frontend.unstract.localhost

    LOGIN_NEXT_URL="http://frontend.unstract.localhost/org"
    LANDING_URL="http://frontend.unstract.localhost/landing"
    ERROR_URL="http://frontend.unstract.localhost/error"
    WEB_APP_ORIGIN_URL="http://frontend.unstract.localhost"

This should be enough to get it running for a different host.

Please try and let us know if it works for you.

Also if possible it would be great if you can help with a new README on how to setup unstract for different host.

@ritwik-g ritwik-g self-assigned this Jun 24, 2024
@haluwong
Copy link
Author

@ritwik-g I tried to following your suggestion to modify .env and labels for unstract-backend and unstract-frontend
also, modified the backend/settings/dev.py in unstract-backend
added our URL in the
CORS_ALLOWED_ORIGINS
CORS_ORIGIN_WHITELIST

Can show the login page but cannot login.
http://unstract.certosa.com/api/v1/session (401 authorized)
screen_20240624_11

@ritwik-g
Copy link
Contributor

ritwik-g commented Jun 24, 2024

@haluwong , when you modified the code (backend/settings/dev.py), you will need to build containers from the local code. Which is acheivable passing -b or --build-local to ./run-platform.sh
image

Hope you have done this.

In any case I don't think this is a CORS error. Can you also share

  • Response of this network call?
  • And also check if any specific error log in the backend?

@haluwong
Copy link
Author

haluwong commented Jun 26, 2024

I downloaded the latest branch.
Try to replace all the "frontend.unstract.localhost" to my desired hostname.
use "./run-platform.sh -b" to build it locally and run it.

Login page can show but will show NetworkError to fetch the source map
screen_20240626_02

But i can access http://unstract.certosa.com/static/js/main.12ab8275.js.map in my browser.

Then, click login and input the username ,password and login and then it will redirect to first login page again.
screen_20240626_05

some js show NetworkError too but I can access it.
And for http://unstract.certosa.com/api/v1/login
Request:
screen_20240626_04

Response:
screen_20240626_03

I tried in both chrome and firefox
redirect to the following landing page after login~
image

Hope this information is useful for your troubleshooting

@ritwik-g
Copy link
Contributor

@haluwong I think the issue is with traefik routing. From the response of login API(/api/v1/login) it looks like to be going to Frontend container instead of backend.

Can you share the screenshot of docker-compose.yaml portions for backend and front-end?

@ritwik-g
Copy link
Contributor

ritwik-g commented Jul 3, 2024

@haluwong I tried this locally and noticed one thing. If you make change in sample.env file in backend then we need to delete the backend/.env file and run the script again. Else the .env file is not updated.

So either delete backend/.env file and run script or make the changes directly in .env file it should work for you

@ritwik-g
Copy link
Contributor

ritwik-g commented Jul 9, 2024

@haluwong had any luck with the above?

@haluwong
Copy link
Author

haluwong commented Jul 10, 2024

Sorry for the late update.
I tried to download the latest version: v0.72.1 and run it in a clean system
decompress and we use grep frontend.unstract.localhost and replace/add our own domain "unstract.certosa.com"
image

Then we run "./run-platform.sh to run the system.
After login it stills redirect back to login page

unstract_20240710-1.mp4

Also, i find that unstract-proxy seems have problem in using the proxy_override.yaml
it's pointed to a directory instead of file.
screen_20240710_07

below is docker-compress.yaml for backend and frontend part
screen_20240710_08
screen_20240710_09

@haluwong
Copy link
Author

_unstract-proxy_logs_0.73.0_20240715.txt
_unstract-frontend_logs_0.73.0_20240715.txt
_unstract-backend_logs_0.73.0_20240715.txt

Attached with backend,frontend and proxy log for your reference.
hope this help to troubleshoot.

About unstract_proxy, it seems the providers file was mapped to a director instead.
image

directory "proxy_overrides.aml" was created after docker-compose

@vivekrathiave
Copy link

@haluwong Since you are using http, also set SESSION_COOKIE_SECURE to False in backend env. or use https.

@ritwik-g
Copy link
Contributor

Hi @haluwong . Will check the logs. Mean while we have created a doc about this. https://docs.unstract.com/unstract_faq/networking/unstract_faq_networking

Can you try following this and update if this works for you?

@ritwik-g ritwik-g added the stale No activity for more than 30days label Aug 12, 2024
@dmnxprss
Copy link

I have noticed a similar issue with this.

  • If I run all services on my desktop, there are no issues and I can access and use the system.
  • If I run all services on my server and want to access it from other devices within the same network, there are issues.

Host On Server & Access On Desktop:

  1. Git clone of latest (0.83.0) and run with no changes, I could access the front page and get to api/v1/login

[Issue] On form submit it redirects to /landing

  1. Adding desktop IP to CORS_ALLOWED_ORIGINS and CORS_ORIGIN_WHITELIST, clean docker images and rebuild

[Issue] On form submit it redirects to /landing

  1. Setting SESSION_COOKIE_SECURE to False, clean docker images and rebuild

[Issue] System goes into a redirect loop between /onboarding and /landing with PermissionDenied('CSRF Failed: CSRF cookie not set.') and Forbidden: /api/v1/organization/mock_org/set

Can you provide any advice?

@ashok-log
Copy link

I too am getting an error when I try accessing remotely. Network trace is given below:

image

@ritwik-g ritwik-g reopened this Sep 12, 2024
@dmnxprss
Copy link

After some Docker & DNS work, I was able to resolve this.

  • Needed some additional work with Traefik container.
  • Employed local certificates so https could be utilized.
  • Updated host name to my preference and with https, where required within files
  • Update internal DNS for new host name

Stack is currently running on local server, accessible within network.

@alancamillo
Copy link

Could you share more detail about it, please?

@ritwik-g ritwik-g removed the stale No activity for more than 30days label Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers question Further information is requested
Projects
None yet
Development

No branches or pull requests

7 participants