[{"data":1,"prerenderedAt":563},["ShallowReactive",2],{"article-20130918-pve-restrict-webui-access":3},{"article":4,"surround":557},{"id":5,"title":6,"authorKey":7,"body":8,"codeLinks":526,"createdAt":527,"description":528,"excerpt":529,"extension":544,"image":545,"meta":546,"navigation":337,"path":547,"published":548,"readingTime":108,"revisedAt":526,"seo":549,"stem":550,"tags":551,"__hash__":556},"articles\u002Farticles\u002F20130918-pve-restrict-webui-access.md","Proxmox VE Restricting Web UI access","philip",{"type":9,"value":10,"toc":521},"minimark",[11,33,36,41,57,61,69,117,120,139,142,145,163,169,176,268,275,426,429,463,472,484,487,501,508,517],[12,13,14,15,25,26,29,30],"p",{},"With the release of ",[16,17,18],"strong",{},[19,20,24],"a",{"href":21,"rel":22},"https:\u002F\u002Fwww.proxmox.com\u002Fde\u002Fnews\u002Fpressemitteilungen\u002Fproxmox-ve-3-0-veroeffentlicht",[23],"nofollow","Proxmox VE 3.0"," back in May 2013, the Proxmox VE web interface does no longer require Apache. Instead, they're using now a new event driven API server called ",[16,27,28],{},"pveproxy",". That was actually a great step ahead, as we all know Apache get's bulkier every day and the new pveproxy is a much more lightweight solution. But the question arose: ",[16,31,32],{},"How do I protect my Proxmox VE WebUI with basic user authentication?",[12,34,35],{},"Basically, we do not trust any web application out there so we better double protect the whole WebUI with plain old basic auth - previously done in Apache by .htaccess.",[37,38,40],"h2",{"id":39},"the-main-idea","The main idea",[42,43,44,50],"ul",{},[45,46,47],"li",{},[16,48,49],{},"Restrict access to the pveproxy (= Web UI) to localhost",[45,51,52,53,56],{},"Install a local ",[16,54,55],{},"Nginx web proxy server"," that forwards requests from port 443 to pveproxy's port 8006 and restrict access to it using HTTP BASIC AUTH",[37,58,60],{"id":59},"restrict-access-to-pveproxy","Restrict access to pveproxy",[12,62,63,64,68],{},"Create a new file ",[65,66,67],"code",{},"\u002Fetc\u002Fdefault\u002Fpveproxy"," with the following content:",[70,71,76],"pre",{"className":72,"code":73,"filename":28,"language":74,"meta":75,"style":75},"language-ini shiki shiki-themes github-light-default github-light-default github-dark-default","ALLOW_FROM=\"127.0.0.1\"\nDENY_FROM=\"all\"\nPOLICY=\"allow\"\n","ini","",[65,77,78,95,106],{"__ignoreMap":75},[79,80,83,87,91],"span",{"class":81,"line":82},"line",1,[79,84,86],{"class":85},"s5nWI","ALLOW_FROM",[79,88,90],{"class":89},"s_bOF","=",[79,92,94],{"class":93},"s-BGO","\"127.0.0.1\"\n",[79,96,98,101,103],{"class":81,"line":97},2,[79,99,100],{"class":85},"DENY_FROM",[79,102,90],{"class":89},[79,104,105],{"class":93},"\"all\"\n",[79,107,109,112,114],{"class":81,"line":108},3,[79,110,111],{"class":85},"POLICY",[79,113,90],{"class":89},[79,115,116],{"class":93},"\"allow\"\n",[12,118,119],{},"Restart pveproxy for the changes to take effect:",[70,121,125],{"className":122,"code":123,"language":124,"meta":75,"style":75},"language-bash shiki shiki-themes github-light-default github-light-default github-dark-default","$ \u002Fetc\u002Finit.d\u002Fpveproxy restart\n","bash",[65,126,127],{"__ignoreMap":75},[79,128,129,133,136],{"class":81,"line":82},[79,130,132],{"class":131},"sQJ0q","$",[79,134,135],{"class":93}," \u002Fetc\u002Finit.d\u002Fpveproxy",[79,137,138],{"class":93}," restart\n",[37,140,55],{"id":141},"nginx-web-proxy-server",[12,143,144],{},"Install nginx-light (the lightweight package of Nginx is sufficient):",[70,146,148],{"className":122,"code":147,"language":124,"meta":75,"style":75},"$ apt-get install nginx-light\n",[65,149,150],{"__ignoreMap":75},[79,151,152,154,157,160],{"class":81,"line":82},[79,153,132],{"class":131},[79,155,156],{"class":93}," apt-get",[79,158,159],{"class":93}," install",[79,161,162],{"class":93}," nginx-light\n",[12,164,165,166],{},"The following packages will be installed: ",[65,167,168],{},"nginx-common nginx-light",[12,170,171,172,175],{},"Now, copy over your signed SSL certificate to ",[65,173,174],{},"\u002Fetc\u002Fnginx\u002Fconf.d",", in case you already have one. You might as well create a self-signed SSL certificate and SSL certificate key, e.g. (validity of 10 years!):",[70,177,179],{"className":122,"code":178,"language":124,"meta":75,"style":75},"$ cd \u002Fetc\u002Fnginx\u002Fconf.d\u002F\n$ openssl genrsa -out server.key 2048\n$ openssl req -new -key server.key -out server.csr\n$ openssl x509 -req -days 3650 -in server.csr -signkey server.key -out server.crt\n",[65,180,181,191,211,233],{"__ignoreMap":75},[79,182,183,185,188],{"class":81,"line":82},[79,184,132],{"class":131},[79,186,187],{"class":93}," cd",[79,189,190],{"class":93}," \u002Fetc\u002Fnginx\u002Fconf.d\u002F\n",[79,192,193,195,198,201,205,208],{"class":81,"line":97},[79,194,132],{"class":131},[79,196,197],{"class":93}," openssl",[79,199,200],{"class":93}," genrsa",[79,202,204],{"class":203},"sDkKp"," -out",[79,206,207],{"class":93}," server.key",[79,209,210],{"class":203}," 2048\n",[79,212,213,215,217,220,223,226,228,230],{"class":81,"line":108},[79,214,132],{"class":131},[79,216,197],{"class":93},[79,218,219],{"class":93}," req",[79,221,222],{"class":203}," -new",[79,224,225],{"class":203}," -key",[79,227,207],{"class":93},[79,229,204],{"class":203},[79,231,232],{"class":93}," server.csr\n",[79,234,236,238,240,243,246,249,252,255,258,261,263,265],{"class":81,"line":235},4,[79,237,132],{"class":131},[79,239,197],{"class":93},[79,241,242],{"class":93}," x509",[79,244,245],{"class":203}," -req",[79,247,248],{"class":203}," -days",[79,250,251],{"class":203}," 3650",[79,253,254],{"class":203}," -in",[79,256,257],{"class":93}," server.csr",[79,259,260],{"class":203}," -signkey",[79,262,207],{"class":93},[79,264,204],{"class":203},[79,266,267],{"class":93}," server.crt\n",[12,269,270,271,274],{},"Create ",[65,272,273],{},"\u002Fetc\u002Fnginx\u002Fsites-available\u002Fpveproxy",":",[70,276,281],{"className":277,"code":278,"filename":279,"language":280,"meta":75,"style":75},"language-nginx shiki shiki-themes github-light-default github-light-default github-dark-default","server {\n        listen          80;\n        server_name     hn*.example.com;\n        rewrite         ^ https:\u002F\u002F$hostname.example.com$request_uri? permanent;\n}\n\nserver {\n        listen                  443 ssl;\n        server_name             hn*.example.com;\n        ssl_certificate         \u002Fetc\u002Fnginx\u002Fconf.d\u002Fserver.crt;\n        ssl_certificate_key     \u002Fetc\u002Fnginx\u002Fconf.d\u002Fserver.key;\n        auth_basic              \"Restricted\";\n        auth_basic_user_file    htpasswd;\n        location \u002F { proxy_pass https:\u002F\u002F127.0.0.1:8006; }\n}\n","sites-available\u002Fpveproxy","nginx",[65,282,283,291,302,310,326,332,339,346,357,365,374,383,394,403,421],{"__ignoreMap":75},[79,284,285,288],{"class":81,"line":82},[79,286,287],{"class":85},"server",[79,289,290],{"class":89}," {\n",[79,292,293,296,299],{"class":81,"line":97},[79,294,295],{"class":85},"        listen ",[79,297,298],{"class":203},"         80",[79,300,301],{"class":89},";\n",[79,303,304,307],{"class":81,"line":108},[79,305,306],{"class":85},"        server_name ",[79,308,309],{"class":89},"    hn*.example.com;\n",[79,311,312,315,318,321,324],{"class":81,"line":235},[79,313,314],{"class":85},"        rewrite",[79,316,317],{"class":93},"         ^ https:\u002F\u002F$",[79,319,320],{"class":89},"hostname.example.com$request_uri? ",[79,322,323],{"class":85},"permanent",[79,325,301],{"class":89},[79,327,329],{"class":81,"line":328},5,[79,330,331],{"class":89},"}\n",[79,333,335],{"class":81,"line":334},6,[79,336,338],{"emptyLinePlaceholder":337},true,"\n",[79,340,342,344],{"class":81,"line":341},7,[79,343,287],{"class":85},[79,345,290],{"class":89},[79,347,349,351,354],{"class":81,"line":348},8,[79,350,295],{"class":85},[79,352,353],{"class":203},"                 443",[79,355,356],{"class":89}," ssl;\n",[79,358,360,362],{"class":81,"line":359},9,[79,361,306],{"class":85},[79,363,364],{"class":89},"            hn*.example.com;\n",[79,366,368,371],{"class":81,"line":367},10,[79,369,370],{"class":85},"        ssl_certificate ",[79,372,373],{"class":89},"        \u002Fetc\u002Fnginx\u002Fconf.d\u002Fserver.crt;\n",[79,375,377,380],{"class":81,"line":376},11,[79,378,379],{"class":85},"        ssl_certificate_key ",[79,381,382],{"class":89},"    \u002Fetc\u002Fnginx\u002Fconf.d\u002Fserver.key;\n",[79,384,386,389,392],{"class":81,"line":385},12,[79,387,388],{"class":85},"        auth_basic ",[79,390,391],{"class":93},"             \"Restricted\"",[79,393,301],{"class":89},[79,395,397,400],{"class":81,"line":396},13,[79,398,399],{"class":85},"        auth_basic_user_file ",[79,401,402],{"class":89},"   htpasswd;\n",[79,404,406,409,412,415,418],{"class":81,"line":405},14,[79,407,408],{"class":85},"        location",[79,410,411],{"class":131}," \u002F ",[79,413,414],{"class":89},"{",[79,416,417],{"class":85}," proxy_pass ",[79,419,420],{"class":89},"https:\u002F\u002F127.0.0.1:8006; }\n",[79,422,424],{"class":81,"line":423},15,[79,425,331],{"class":89},[12,427,428],{},"Disable the default site and enable pveproxy:",[70,430,432],{"className":122,"code":431,"language":124,"meta":75,"style":75},"$ rm -f \u002Fetc\u002Fnginx\u002Fsites-enabled\u002Fdefault\n$ ln -sf \u002Fetc\u002Fnginx\u002Fsites-available\u002Fpveproxy \u002Fetc\u002Fnginx\u002Fsites-enabled\u002F\n",[65,433,434,447],{"__ignoreMap":75},[79,435,436,438,441,444],{"class":81,"line":82},[79,437,132],{"class":131},[79,439,440],{"class":93}," rm",[79,442,443],{"class":203}," -f",[79,445,446],{"class":93}," \u002Fetc\u002Fnginx\u002Fsites-enabled\u002Fdefault\n",[79,448,449,451,454,457,460],{"class":81,"line":97},[79,450,132],{"class":131},[79,452,453],{"class":93}," ln",[79,455,456],{"class":203}," -sf",[79,458,459],{"class":93}," \u002Fetc\u002Fnginx\u002Fsites-available\u002Fpveproxy",[79,461,462],{"class":93}," \u002Fetc\u002Fnginx\u002Fsites-enabled\u002F\n",[12,464,465,466,471],{},"For details, check ",[19,467,470],{"href":468,"rel":469},"http:\u002F\u002Fnginx.org\u002Fen\u002Fdocs\u002Fhttp\u002Fngx_http_ssl_module.html",[23],"NGINX ngx_http_ssl_module",". Note that the certificates could also be placed in another directory (adjust \u002Fetc\u002Fnginx\u002Fnginx.conf accordingly).",[12,473,474,475,478,479],{},"Create the htpasswd file in ",[65,476,477],{},"\u002Fetc\u002Fnginx\u002Fhtpasswd","\nI'd recommend to simply create it on another host where you have Apache installed. But in case you have no such tools at hand, check the ",[19,480,483],{"href":481,"rel":482},"https:\u002F\u002Fwww.nginx.com\u002Fresources\u002Fwiki\u002Fcommunity\u002Ffaq\u002F#how-do-i-generate-an-htpasswd-file-without-having-apache-tools-installed",[23],"FAQ: How do I generate an .htpasswd file without having Apache tools installed?",[12,485,486],{},"Restart Nginx:",[70,488,490],{"className":122,"code":489,"language":124,"meta":75,"style":75},"$ \u002Fetc\u002Finit.d\u002Fnginx restart\n",[65,491,492],{"__ignoreMap":75},[79,493,494,496,499],{"class":81,"line":82},[79,495,132],{"class":131},[79,497,498],{"class":93}," \u002Fetc\u002Finit.d\u002Fnginx",[79,500,138],{"class":93},[12,502,503,504,507],{},"Done! You may now access the Proxmox VE Web UI directly via ",[65,505,506],{},"HTTPS"," - no separate port required as we are using the standard SSL port 443 for our NGINX proxy.",[12,509,510,511,516],{},"Credits to: ",[19,512,515],{"href":513,"rel":514},"https:\u002F\u002Fprintscreen.ch\u002F",[23],"Printscreen GmbH, Daniel Mettler"," - Thanks for helping me out with NGINX!",[518,519,520],"style",{},"html pre.shiki code .s5nWI, html code.shiki .s5nWI{--shiki-light:#CF222E;--shiki-default:#CF222E;--shiki-dark:#FF7B72}html pre.shiki code .s_bOF, html code.shiki .s_bOF{--shiki-light:#1F2328;--shiki-default:#1F2328;--shiki-dark:#E6EDF3}html pre.shiki code .s-BGO, html code.shiki .s-BGO{--shiki-light:#0A3069;--shiki-default:#0A3069;--shiki-dark:#A5D6FF}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sQJ0q, html code.shiki .sQJ0q{--shiki-light:#953800;--shiki-default:#953800;--shiki-dark:#FFA657}html pre.shiki code .sDkKp, html code.shiki .sDkKp{--shiki-light:#0550AE;--shiki-default:#0550AE;--shiki-dark:#79C0FF}",{"title":75,"searchDepth":97,"depth":108,"links":522},[523,524,525],{"id":39,"depth":97,"text":40},{"id":59,"depth":97,"text":60},{"id":141,"depth":97,"text":55},null,"2013-09-18","How to password protect the web UI of Proxmox VE.",{"type":9,"value":530},[531,542],[12,532,14,533,25,538,29,540],{},[16,534,535],{},[19,536,24],{"href":21,"rel":537},[23],[16,539,28],{},[16,541,32],{},[12,543,35],{},"md","\u002Fimages\u002Fcovers\u002Fproxmoxve-webui.png",{},"\u002Farticles\u002F20130918-pve-restrict-webui-access",false,{"title":6,"description":528},"articles\u002F20130918-pve-restrict-webui-access",[552,553,554,555],"sysadmin","linux","proxmoxve","security","DSK-Ws09fo__sjl3cHC1iy7BAmyFEeuPmjr8fC7JFek",[526,558],{"title":559,"path":560,"stem":561,"createdAt":562,"children":-1},"Process hiding - hidepid capabilities of procfs","\u002Farticles\u002F20130930-hidepid-process-hiding","articles\u002F20130930-hidepid-process-hiding","2013-09-30",1794961391668]