retspen / webvirtmgr

WebVirtMgr panel for manage virtual machine
http://retspen.github.io
2.05k stars 537 forks source link

[feature req] WebVirtMgr on /manage #472

Open MedicMomcilo opened 10 years ago

MedicMomcilo commented 10 years ago

Hi friends! This is some awesome software and I absolutely love it! :)

Is it possible to have the option to move it from / on server to something else? I know using web from outside is not recommended, but I tend to manage my server from work (read: windows box) so I cannot setup ssh tunnel.

I saw #249 and tried adding /manage to urls.py and it works for some parts, not for login (I have to manualy type /manage/login) and for noVNC (I have to manualy add /manage/ in the link)

So, can we have this issue open until someone comes by who knows how to implement this?

Thanks for this awesome piece of art.

NicolasPaccaud commented 9 years ago

Same problem here; I've tried couple of things; rewriting urls.py does not work, some url seems to be hardcoded as you seen. Even tried to play with rewrite url in the nginx conf for webvirtmgr but failed to achieve a working configuration.

Using / or /whatever as no relation with security or outside access; this should be left to specific other solution (ip restrictions, vpn, , ...)

Hope we can find a solution to that.

IlGab78 commented 9 years ago

Maybe I'm little bit late on this but someone can found this useful. My environment is webvirtmgr on arch linux and apache2.4 + mod_wsgi (I don't want use nginx). I move the root from http://ip.of.the.server/ to http://ip.of.the.server/webvirtmgr Path for webvirtmgr on server is /usr/lib/webvirtmgr/

1) install and enable mod_wsgi2 in apache (wsgi2 is for python 2.x only) pacman -S community/mod_wsgi2

2) Load the module in apache LoadModule wsgi_module modules/mod_wsgi.so

3) add this to your apache config ( Require all granted is for apache 2.4 not 2.2)

WSGIScriptAlias /webvirtmgr /usr/lib/webvirtmgr/webvirtmgr/wsgi.py WSGIPythonPath /usr/lib/webvirtmgr/ Alias /static /usr/lib/webvirtmgr/static/ < Directory /usr/lib/webvirtmgr/webvirtmgr/> < Files wsgi.py> Require all granted < /Files> < /Directory>

< Directory /usr/lib/webvirtmgr/static/> AllowOverride None Require all granted < /Directory>"

4) chenge /usr/lib/webvirtmgr/webvirtmgr/urls.py to allow novnc to work properly

from url(r'^console/$', 'console.views.console', name='console'),

to url(r'^webvirtmgr/console/$', 'console.views.console', name='console'),

5) change the owner of secret_key_store to http server's user chown http /usr/lib/webvirtmgr/webvirtmgr/local/.secret_key_store

6) happy surfing on http:///webvirtmgr

fulminemizzega commented 9 years ago

Hi all. After a very long (I know pretty much nothing about webserving/nginx) research I found something almost working but with nginx instead of apache.

This is the NGINX configuration part, taken right from documentation and slightly modified:

server {
    listen 80 default_server;

    server_name $server_addr;
    #access_log /var/log/nginx/webvirtmgr_access_log;

    location /static/ {
        root /opt/webvirtmgr/webvirtmgr; # or /srv instead of /var
        expires max;
    }

    location /vm/ {
        proxy_pass http://127.0.0.1:8000;
        proxy_set_header SCRIPT_NAME /vm;
        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_connect_timeout 600;
        proxy_read_timeout 600;
        proxy_send_timeout 600;
        client_max_body_size 1024M; # Set higher depending on your needs
    }
}

I want webvirtmgr to be in http://mysrv/vm. What set me on the right direction was http://albertoconnor.ca/blog/2011/Sep/15/hosting-django-under-different-locations I just changed location / to location /vm/ and added proxy_set_header SCRIPT_NAME /vm;

Still, console does not work. I tried changing urls.py, but it looks like the setting does not do anything (restarted supervisor after each change), it still goes to http://mysrv/console... Another issue is that I still haven't managed to move /static to /vm/static, this config is not working.

How is it possible that you can't host webvirtmgr anywhere besides root??

Another route I tried but failed (probably because of my lack of knowledge): run nginx to host webvirtmgr on port 8001, then use another nginx proxy on port 80 with location /vm/ and proxy_pass to it. Every time the url was rewritten without /vm/, so redirection failed.