{"id":23,"date":"2023-04-05T00:16:56","date_gmt":"2023-04-04T22:16:56","guid":{"rendered":"https:\/\/gilbert.busana.lu\/?p=23"},"modified":"2023-04-05T17:26:46","modified_gmt":"2023-04-05T15:26:46","slug":"nginx-redirect-all-http-traffic-to-https","status":"publish","type":"post","link":"https:\/\/www.homeserver.lu\/?p=23","title":{"rendered":"NGINX: redirect all HTTP traffic to HTTPS"},"content":{"rendered":"\n<p>To redirect all traffic from non secure to secure sockets layer (SSL), add the following lines to the virtual host config file in <em>\/etc\/nginx\/sites-available\/my_vhost_config_file<\/em>.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>server {\n    listen 80 default_server;\n    server_name _;\n    return 301 https:\/\/$host$request_uri;\n}<\/code><\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Explanations:<\/h3>\n\n\n\n<p><strong>Listen 80: <\/strong>This instructs the system to catch all HTTP traffic on Port 80<br><strong>Server_name _; :<\/strong> This will match any hostname<br><strong>Return 301: <\/strong>This tells the browser (and search engines) that this is a permanent redirect<br><strong>https:\/\/$host$request_uri: <\/strong>This is a short code to specify the HTTPS version of whatever the user has typed<\/p>\n","protected":false},"excerpt":{"rendered":"<p>To redirect all traffic from non secure to secure sockets layer (SSL), add the following lines to the virtual host config file in \/etc\/nginx\/sites-available\/my_vhost_config_file. Explanations: Listen 80: This instructs the system to catch all HTTP traffic on Port 80Server_name _; : This will match any hostnameReturn 301: This tells the browser (and search engines) that [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[16,15],"tags":[],"class_list":["post-23","post","type-post","status-publish","format-standard","hentry","category-reverse-proxy","category-webserver"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.homeserver.lu\/index.php?rest_route=\/wp\/v2\/posts\/23","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.homeserver.lu\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.homeserver.lu\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.homeserver.lu\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.homeserver.lu\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=23"}],"version-history":[{"count":6,"href":"https:\/\/www.homeserver.lu\/index.php?rest_route=\/wp\/v2\/posts\/23\/revisions"}],"predecessor-version":[{"id":32,"href":"https:\/\/www.homeserver.lu\/index.php?rest_route=\/wp\/v2\/posts\/23\/revisions\/32"}],"wp:attachment":[{"href":"https:\/\/www.homeserver.lu\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=23"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.homeserver.lu\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=23"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.homeserver.lu\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=23"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}