[GH-ISSUE #418] How to run webvirtcloud behind nginx with a sub directory #256

Open
opened 2026-02-27 15:57:59 +03:00 by kerem · 4 comments
Owner

Originally created by @KMFtcy on GitHub (Mar 26, 2021).
Original GitHub issue: https://github.com/retspen/webvirtcloud/issues/418

Hi there. I'm running webvirtcloud service behind a nginx from public network.

The expose url like this: http://domain:port/webcirtcloud/. My nginx config was like :

location /webvirtcloud {
        client_max_body_size 20m;
        client_body_buffer_size 256k;
        proxy_connect_timeout 180s;
        proxy_send_timeout 180s;
        proxy_read_timeout 180s;
        proxy_buffer_size 128k;
        proxy_buffers 32 64k;
        proxy_busy_buffers_size 128k;
        proxy_temp_file_write_size 128k;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_pass  http://127.0.0.1:4001/;
}

4001 is where the webvirtcloud service exposed.

When I accessed, I was redirected to : http://domain/accounts/login/ , even the port has been deleted.

How can I config webvirtcloud to satisfy this need ?

Originally created by @KMFtcy on GitHub (Mar 26, 2021). Original GitHub issue: https://github.com/retspen/webvirtcloud/issues/418 Hi there. I'm running webvirtcloud service behind a nginx from public network. The expose url like this: http://domain:port/webcirtcloud/. My nginx config was like : ``` location /webvirtcloud { client_max_body_size 20m; client_body_buffer_size 256k; proxy_connect_timeout 180s; proxy_send_timeout 180s; proxy_read_timeout 180s; proxy_buffer_size 128k; proxy_buffers 32 64k; proxy_busy_buffers_size 128k; proxy_temp_file_write_size 128k; proxy_set_header Host $host; proxy_set_header X-Forwarded-Proto $scheme; proxy_pass http://127.0.0.1:4001/; } ``` 4001 is where the webvirtcloud service exposed. When I accessed, I was redirected to : http://domain/accounts/login/ , even the port has been deleted. How can I config webvirtcloud to satisfy this need ?
Author
Owner

@catborise commented on GitHub (Mar 26, 2021):

        proxy_pass http://127.0.0.1:4001;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-for $proxy_add_x_forwarded_for;
        proxy_set_header Host $host:$server_port;
        proxy_set_header X-Forwarded-Proto $remote_addr;
        proxy_set_header X-Forwarded-Ssl off;

you should rearange proxy_set_header. we use this as a default config. you can try it.

<!-- gh-comment-id:807950365 --> @catborise commented on GitHub (Mar 26, 2021): ``` proxy_pass http://127.0.0.1:4001; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-for $proxy_add_x_forwarded_for; proxy_set_header Host $host:$server_port; proxy_set_header X-Forwarded-Proto $remote_addr; proxy_set_header X-Forwarded-Ssl off; ``` you should rearange proxy_set_header. we use this as a default config. you can try it.
Author
Owner

@KMFtcy commented on GitHub (Mar 26, 2021):

@catborise
Thanks for your reply. I have done what you say but it doesn't work.

The problem is not nginx problem. I can access webvirtcloud actually. The problem is url_root or base_url.

When I access webvirtcloud, it redirect to http://domain/accounts/login/, but it ought to be http://domain/webcirtcloud/accounts/login/ in my case.

Look forward to your further suggestions.

<!-- gh-comment-id:808015667 --> @KMFtcy commented on GitHub (Mar 26, 2021): @catborise Thanks for your reply. I have done what you say but it doesn't work. The problem is not nginx problem. I can access webvirtcloud actually. The problem is url_root or base_url. When I access webvirtcloud, it redirect to http://domain/accounts/login/, but it ought to be http://domain/webcirtcloud/accounts/login/ in my case. Look forward to your further suggestions.
Author
Owner

@KMFtcy commented on GitHub (Mar 26, 2021):

By the way, it do fix the port problems. Many thanks for that.

<!-- gh-comment-id:808030041 --> @KMFtcy commented on GitHub (Mar 26, 2021): By the way, it do fix the port problems. Many thanks for that.
Author
Owner

@hfftjp commented on GitHub (Jan 13, 2024):

For your information
This solution is at "apache+mod_wsgi" and commit "d24d6b037d".

  1. Change or add at /srv/webvirtcloud/webvirtcloud/settings.py
LOGIN_URL = "/sub_dir_name/accounts/login/"
LOGIN_REDIRECT_URL="/sub_dir_name/instances/"
LOGOUT_REDIRECT_URL = "/sub_dir_name/accounts/login/"
STATIC_URL = "/sub_dir_name/static/"
  1. Add at /srv/webvirtcloud/webvirtcloud/urls.py
    path("accounts/", include("accounts.urls")),
    path("sub_dir_name/accounts/", include("accounts.urls")), # add this entry  ( NOTE! : add it after the normal entry )
<!-- gh-comment-id:1890381545 --> @hfftjp commented on GitHub (Jan 13, 2024): For your information This solution is at "apache+mod_wsgi" and commit "d24d6b037de55fd11bdc7cbaf788aefb93b3635e". 1) Change or add at /srv/webvirtcloud/webvirtcloud/settings.py ``` LOGIN_URL = "/sub_dir_name/accounts/login/" LOGIN_REDIRECT_URL="/sub_dir_name/instances/" LOGOUT_REDIRECT_URL = "/sub_dir_name/accounts/login/" STATIC_URL = "/sub_dir_name/static/" ``` 2) Add at /srv/webvirtcloud/webvirtcloud/urls.py ``` path("accounts/", include("accounts.urls")), path("sub_dir_name/accounts/", include("accounts.urls")), # add this entry ( NOTE! : add it after the normal entry ) ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/webvirtcloud#256
No description provided.