How to run webvirtcloud behind nginx with a sub directory
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 ?
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.
@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.
By the way, it do fix the port problems. Many thanks for that.
For your information This solution is at "apache+mod_wsgi" and commit "d24d6b037de55fd11bdc7cbaf788aefb93b3635e".
- 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/"
- 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 )