{"id":1960,"date":"2022-07-15T02:17:56","date_gmt":"2022-07-15T09:17:56","guid":{"rendered":"https:\/\/dimitrakarakou.gr\/digitalmedia\/?p=1960"},"modified":"2022-11-16T02:32:05","modified_gmt":"2022-11-16T09:32:05","slug":"geoserver-installation-and-its-connection-over-https","status":"publish","type":"post","link":"https:\/\/dimitrakarakou.gr\/digitalmedia\/geoserver-installation-and-its-connection-over-https\/","title":{"rendered":"Geoserver installation and its connection over https"},"content":{"rendered":"<p>Currently, I am exploring the GIS, developing a web environment for exploring the changes in Attika land by creating a comparative online space for the \u2018Karten von Attika\u2019, the 19th-century maps of Attika land (Greece) and a contemporary one from the Openstreet map.<\/p>\n<p>This is article presents the process of creating a web-map environment by using QGIS software and Geoserver. Maps are stored on Geoserver in an external virtual machine and the WMS layer is used to load in the QGIS project. When a website uses https protocol the virtual machine that hosts the Geoserver must be secured as well because https communicate and work properly with https thus Geoserver has to be connected over https.<\/p>\n<p><strong>Geoserver installation<\/strong><\/p>\n<p>GeoServer is an open-source server for sharing geospatial data,<br \/>\nit will be installed in an external virtual machine that has Ubuntu 20.04 O.S.<\/p>\n<p>Run the virtual machine and update it with the latest apt packages.<\/p>\n<pre>sudo apt update<\/pre>\n<pre>sudo apt upgrate<\/pre>\n<p>Geoserver requires Java. Install it by running<\/p>\n<pre class=\"highlight-height line-numbers language-javascript\" data-line=\"\"><code class=\"language-javascript\">sudo apt install <span class=\"token keyword\">default<\/span><span class=\"token operator\">-<\/span>jdk <span class=\"token operator\">-<\/span>y<\/code><\/pre>\n<p>Check if Java is installed<\/p>\n<pre>java -version<\/pre>\n<p>and if the output is the below, Java is in the V.M<\/p>\n<pre>openjdk 11.0.17 2022-10-18\r\nOpenJDK Runtime Environment (build 11.0.17+8-post-Ubuntu-1ubuntu222.04)\r\nOpenJDK 64-Bit Server VM (build 11.0.17+8-post-Ubuntu-1ubuntu222.04, mixed mode, sharing)\r\n<\/pre>\n<p>Download the Geoserver 2.21<\/p>\n<pre>wget https:\/\/sourceforge.net\/projects\/geoserver\/files\/GeoServer\/2.21.0\/geoserver-2.21.0-bin.zip\r\n<\/pre>\n<p>Create a geoserver directory in \/usr\/share folder<\/p>\n<pre>mkdir \/usr\/share\/geoserver\r\n<\/pre>\n<p>Extract the downloaded zip file in the above geoserver folder<\/p>\n<pre>unzip -d \/usr\/share\/geoserver\/geoserver-2.21.0-bin.zip\r\n<\/pre>\n<p>Create\u00a0a\u00a0geoserver user<\/p>\n<pre>sudo useradd -m -U -s \/bin\/false geoserver\r\n<\/pre>\n<p>Set this geoserver user as the ownership of the geoserver directory:<\/p>\n<pre>sudo chown -R geoserver:geoserver \/usr\/share\/geoserver\r\n<\/pre>\n<p>Create a <strong>Systemd<\/strong> service file for GeoServer<\/p>\n<pre>sudo nano \/usr\/lib\/systemd\/system\/geoserver.service\r\n<\/pre>\n<p>and write the bellow<\/p>\n<pre>[Unit]\r\nDescription=GeoServer Service\r\nAfter=network.target\r\n\r\n[Service]\r\nType=simple\r\n\r\nUser=geoserver\r\nGroup=geoserver\r\n\r\nEnvironment=\"GEOSERVER_HOME=\/usr\/share\/geoserver\"\r\n\r\nExecStart=\/usr\/share\/geoserver\/bin\/startup.sh\r\nExecStop=\/usr\/share\/geoserver\/bin\/shutdown.sh\r\n\r\n[Install]\r\nWantedBy=multi-user.target\r\n<\/pre>\n<p>Reload the systemd daemon.<\/p>\n<pre>sudo systemctl daemon-reload\r\n<\/pre>\n<p>Start and enable the GeoServer at system reboot<\/p>\n<pre>sudo systemctl enable --now geoserver\r\n<\/pre>\n<p>Check the status of the GeoServer<\/p>\n<pre>sudo systemctl status geoserver\r\n<\/pre>\n<p>and if you see<\/p>\n<pre>Active: active (running)<\/pre>\n<p>ok!<\/p>\n<p>Geoserver listens on port 8080 Type on you browser virtual machine&#8217;s IP address e.g\u00a0<strong>xxx.xxx.xxx.xxx:8080\/geoserver<\/strong><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-2067\" src=\"https:\/\/dimitrakarakou.gr\/digitalmedia\/wp-content\/uploads\/2022\/07\/Geoserver.jpg\" alt=\"Geoserver\" width=\"600\" height=\"265\" \/><\/p>\n<p>An SSL certificate enables an encrypted connection (HTTPS) There are many hosts and certificate authorities (CA), like <strong>Let\u2019s Encrypt<\/strong>.<\/p>\n<p>Prerequisites and requirements to install Let\u2019s Encrypt SSL certificate.<br \/>\n1. Ubuntu 20.04 installed<br \/>\n2. Ability to manage your domain\u2019s DNS records. Let\u2019s Encrypt works with a fully registered domain name e.g example.com<br \/>\n3. Apache2 installed and active. An Apache2 virtual host configured for your website: example.com<\/p>\n<p><strong>DNS records<\/strong><br \/>\nYou have to log in to your domain provider and add DNS records for example.com<br \/>\nAn A record with your_domain pointing to your server\u2019s public IP address.<br \/>\nAn A record with www.your_domain pointing to your server\u2019s public IP address.<\/p>\n<p><strong>Apache HTTP Server <\/strong><\/p>\n<p><strong>Installing Apache in Ubuntu 20.04<\/strong><\/p>\n<pre>sudo apt install apache2 \r\n<\/pre>\n<p>Start Apache<\/p>\n<pre>sudo service apache2 start\r\n<\/pre>\n<p>The html content of apache is stored inside the html folder that is in \/var\/www\/<br \/>\nCreate a new folder to store your webpage,\u00a0 e.g example (the same name as your domain name) and I created a simple index.html file inside this folder.<br \/>\nApache has to serve this new content instead the default html one, a new virtual host has to be created.<br \/>\nThe Apache\u2019s virtual hosts are stored in \/etc\/apache2\/sites-available<\/p>\n<p>Navigate to this location<\/p>\n<pre>cd \/etc\/apache2\/sites-available\/<\/pre>\n<p>The default configuration is the 000-default.conf Instead of modifying the default configuration file, create a new one: example.conf<\/p>\n<pre>sudo nano \/etc\/apache2\/sites-available\/example.conf<\/pre>\n<p>and add the following.<\/p>\n<pre>&lt;VirtualHost *:80&gt; \r\nServerAdmin my@email.com \r\nServerName example.com \r\nServerAlias www.example.com \r\nDocumentRoot \/var\/www\/example \r\nErrorLog ${APACHE_LOG_DIR}\/error.log \r\nCustomLog ${APACHE_LOG_DIR}\/access.log combined \r\n&lt;\/VirtualHost&gt;<\/pre>\n<p>Enable this new configuration file by using the a2ensite tool:<\/p>\n<pre>sudo a2ensite example.conf \r\n<\/pre>\n<p>Disable the default configuration file : 000-default.conf<\/p>\n<pre>sudo a2dissite 000-default.conf<\/pre>\n<p>Test this for configuration errors<\/p>\n<pre>sudo apache2ctl configtest \r\n<\/pre>\n<p>You should receive the following output<\/p>\n<pre>Output\r\nSyntax OK \r\n<\/pre>\n<p>Restart Apache<\/p>\n<pre>sudo systemctl restart apache2<\/pre>\n<p>Open a browser <strong>http:\/\/example.com:8080\/geoserver<\/strong> to see Geoserver page<\/p>\n<p>In this case Apache proxies\u00a0<strong>http:\/\/example.com\/geoserver<\/strong>\u00a0requests\u00a0 to the <strong>http:\/\/example.com:8080\/geoserver<\/strong>.<br \/>\nBackend server receives the request and sent the respond to the apache, which then generates the actual HTTP response back to the client.<\/p>\n<p>Set up Apache as a reverse proxy server on Ubuntu 20.04, the following modules must be enabled by running the following commands:<\/p>\n<pre>sudo a2enmod proxy\r\nsudo a2enmod proxy_http\r\n<\/pre>\n<p>The example.conf file has to be replaced by the following<br \/>\nThe &#8220;ProxyPass&#8221; and &#8220;ProxyPassReverse&#8221; parameters are used to tell Apache how to proxy requests.<\/p>\n<pre>&lt;VirtualHost *:80&gt; \r\nServerAdmin my@e-mail.com \r\nServerName example.com \r\nServerAlias www.example.com \r\nDocumentRoot \/var\/www\/example \r\nErrorLog ${APACHE_LOG_DIR}\/error.log \r\nCustomLog ${APACHE_LOG_DIR}\/access.log combined \r\n ProxyRequests On\r\n ProxyPass \/geoserver\/ http:\/\/example.com:8080\/geoserver\/\r\n ProxyPassReverse \/geoserver\/ http:\/\/example.com\/geoserver\/\r\n &lt;Location \/geoserver&gt;\r\n Order allow,deny\r\n Allow from all\r\n &lt;\/Location&gt;\r\n&lt;\/VirtualHost&gt;<\/pre>\n<p>Now you can type the address without port number http:\/\/example.com\/geoserver<\/p>\n<p><strong>SSL Let\u2019s Encrypt <\/strong><\/p>\n<p>Install the Certbot, a command-line utility\u00a0that is used to get the certificate.<br \/>\nIt helps to get and renew the SSL certificate when needed. It is available in the official APT package repository of Ubuntu.<br \/>\nStart the installation process of Certbot and python3-certbot-apache.<\/p>\n<pre>sudo apt install certbot python3-certbot-apache<\/pre>\n<p>Allow HTTPS traffic the default and pre-installed UFW firewall must be enabled to modify the firewall rules.<br \/>\nCheck UFW firewall<\/p>\n<pre>sudo ufw status<\/pre>\n<p>It will show all the rules running if there are any.<br \/>\nIf the status is inactive, enable the ufw utility using the command:<\/p>\n<pre>sudo ufw enable<\/pre>\n<p>Check the status again<\/p>\n<p>Allow the Apache Full by running the below command<\/p>\n<pre>sudo ufw allow 'Apache Full'<\/pre>\n<p>Check the status of UFW again to verify the new configuration<\/p>\n<pre>sudo ufw status<\/pre>\n<p>and see<\/p>\n<pre>Apache Full Allow Anywhere\r\nApache Full(v6) Allow Anywhere\r\n<\/pre>\n<p>Get the Let\u2019s Encrypt SSL certificate<br \/>\nGet the SSL certificate using the Certbot by typing the command given below:<\/p>\n<pre>sudo certbot --apache -d example.com -d www.example.com\r\n<\/pre>\n<p>The execution of the above command will prompt a couple of questions, so read them carefully and answer accordingly as per your requirements and needs.<\/p>\n<p><strong>Handling maps to Geoserver, the GeoCat Bridge plugin<br \/>\n<\/strong><\/p>\n<p>When your map project has been completed, maps are ready to be uploaded on the Geoserver.<br \/>\nThe GeoCat Bridge plugin easily publishes data and metadata from QGIS to Geoserver.<\/p>\n<p>Go to QGOS project Plugins &#8211;&gt; &#8216;Manage and Install Plugins&#8217; <img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-2074\" src=\"https:\/\/dimitrakarakou.gr\/digitalmedia\/wp-content\/uploads\/2022\/07\/GeocatBridge_Plugin.jpg\" alt=\"GeocatBridge_Plugin\" width=\"600\" height=\"216\" \/>Create a new Geoserver<br \/>\nGive a name,<br \/>\ntype its address: https:\/\/examples.com\/geoserver<br \/>\nRequires <strong>authentication<\/strong> and the default login values of Geoserver is <strong>username: admin and password geoserver<\/strong><br \/>\n<img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-2056\" src=\"https:\/\/dimitrakarakou.gr\/digitalmedia\/wp-content\/uploads\/2022\/07\/GeocatBridge00.jpg\" alt=\"GeocatBridge00\" width=\"600\" height=\"474\" \/> When the server is ready click publish tab <img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-2055\" src=\"https:\/\/dimitrakarakou.gr\/digitalmedia\/wp-content\/uploads\/2022\/07\/GeocatBridge.png\" alt=\"GeocatBridge\" width=\"700\" height=\"536\" \/><\/p>\n<p>Now you can create a new QGIS project and load the maps from the Geoserever.<\/p>\n<p>Go to &#8211;&gt; Layer &#8211;&gt;Add Layer &#8211;&gt; Add WMS\/WMTS Layer &#8230;<br \/>\n<img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-2079\" src=\"https:\/\/dimitrakarakou.gr\/digitalmedia\/wp-content\/uploads\/2022\/07\/WMS-WMTSLayer.jpg\" alt=\"Add_WMS_WMTS Layer\" width=\"311\" height=\"500\" \/> Click ok<\/p>\n<p>Connect with the Geoserver and when a connection is established you can select the map file that you want to load on the WMS\/WMTS Layer<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-2081\" src=\"https:\/\/dimitrakarakou.gr\/digitalmedia\/wp-content\/uploads\/2022\/07\/WMS-WMTSLayer02.jpg\" alt=\"Add_WMS_WMTS Layer_02\" width=\"800\" height=\"580\" \/><\/p>\n<p>Click add<br \/>\n<img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-2083\" src=\"https:\/\/dimitrakarakou.gr\/digitalmedia\/wp-content\/uploads\/2022\/07\/WMS-WMTSLayer03.jpg\" alt=\"Add_WMS_WMTSLayer_03\" width=\"800\" height=\"419\" \/><\/p>\n<p><strong>The qgis2web plugin, creating a web environment<\/strong><\/p>\n<p>Webmap environment can be easily created with the qgis2web plugin that exports to an OpenLayers or Leaflet webmap from your current QGIS project.<\/p>\n<p><a href=\"https:\/\/dimitrakarakou.gr\/digitalmedia\/wp-content\/uploads\/2022\/07\/qgis2web.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-2086\" src=\"https:\/\/dimitrakarakou.gr\/digitalmedia\/wp-content\/uploads\/2022\/07\/qgis2web.jpg\" alt=\"qgis2web\" width=\"387\" height=\"219\" \/><\/a> \u00a0 Select your preferences <img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-2098\" src=\"https:\/\/dimitrakarakou.gr\/digitalmedia\/wp-content\/uploads\/2022\/07\/qgis2web_preferemces.jpg\" alt=\"qgis2web_preferemces\" width=\"609\" height=\"700\" \/><\/p>\n<p>When done click export<br \/>\nThis exports a whole environment in a folder: <strong>qgis2web_the_timestamp, (the_timestamp: = the current time of this export)<\/strong><\/p>\n<p>When the project&#8217;s development is completed, it can be loaded on your web server.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Currently, I am exploring the GIS, developing a web environment for exploring the changes in Attika land by creating a comparative online space for the \u2018Karten von Attika\u2019, the 19th-century maps of Attika land (Greece) and a contemporary one from the Openstreet map. This is article presents the process of creating a web-map environment by &#8230; <a class=\"more-link1960 \" href=\"https:\/\/dimitrakarakou.gr\/digitalmedia\/geoserver-installation-and-its-connection-over-https\/\"><span style=\"font-weight: 900; color: #000; font-family: 'Delius Swash Caps', cursive;\">Take a further walk&#8230;<\/span>  <img decoding=\"async\" class=\"catFootprints1960\" src=\"\"><\/a><\/p>\n","protected":false},"author":1,"featured_media":2146,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[78],"tags":[80,28],"_links":{"self":[{"href":"https:\/\/dimitrakarakou.gr\/digitalmedia\/wp-json\/wp\/v2\/posts\/1960"}],"collection":[{"href":"https:\/\/dimitrakarakou.gr\/digitalmedia\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dimitrakarakou.gr\/digitalmedia\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dimitrakarakou.gr\/digitalmedia\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dimitrakarakou.gr\/digitalmedia\/wp-json\/wp\/v2\/comments?post=1960"}],"version-history":[{"count":118,"href":"https:\/\/dimitrakarakou.gr\/digitalmedia\/wp-json\/wp\/v2\/posts\/1960\/revisions"}],"predecessor-version":[{"id":2155,"href":"https:\/\/dimitrakarakou.gr\/digitalmedia\/wp-json\/wp\/v2\/posts\/1960\/revisions\/2155"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dimitrakarakou.gr\/digitalmedia\/wp-json\/wp\/v2\/media\/2146"}],"wp:attachment":[{"href":"https:\/\/dimitrakarakou.gr\/digitalmedia\/wp-json\/wp\/v2\/media?parent=1960"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dimitrakarakou.gr\/digitalmedia\/wp-json\/wp\/v2\/categories?post=1960"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dimitrakarakou.gr\/digitalmedia\/wp-json\/wp\/v2\/tags?post=1960"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}