<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: bwieckow</title>
    <description>The latest articles on DEV Community by bwieckow (@bwieckow).</description>
    <link>https://dev.to/bwieckow</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F621260%2F34be352d-c312-46b9-b96f-e0cebed9078a.png</url>
      <title>DEV Community: bwieckow</title>
      <link>https://dev.to/bwieckow</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/bwieckow"/>
    <language>en</language>
    <item>
      <title>Custom domain for Pay-As-You-Go Azure App Service</title>
      <dc:creator>bwieckow</dc:creator>
      <pubDate>Mon, 26 Apr 2021 17:13:03 +0000</pubDate>
      <link>https://dev.to/bwieckow/custom-domain-for-pay-as-you-go-azure-app-service-chn</link>
      <guid>https://dev.to/bwieckow/custom-domain-for-pay-as-you-go-azure-app-service-chn</guid>
      <description>&lt;p&gt;Having your application deployed to AppService in Azure with cheapest AppService Plan you are not allowed to customize your domain. Here I will show you how you can quickly overcome it with your own server.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--P046EtQE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d5bacgpvuhnk3yb2su5j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--P046EtQE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d5bacgpvuhnk3yb2su5j.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Prerequisites:
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Having server accessible via SSH constantly running.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;SSL certificates generated. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;(NOTE: You can easily generate your SSL certificates with &lt;a href="https://letsencrypt.org/"&gt;Let’s Encrypt&lt;/a&gt;)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;DNS entry poinit &lt;code&gt;secrets.your.domain&lt;/code&gt; to IP of your server:&lt;br&gt;
&lt;code&gt;secrets.your.domain.  59         IN          A           104.245.210.170&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Setting up custom domain
&lt;/h1&gt;

&lt;p&gt;If you have all above configured you are able to follow below steps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;    Log in to your server.&lt;/li&gt;
&lt;li&gt;    Install NGINX on your OS. E.g CentOS:
   &lt;code&gt;sudo yum install nginx&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;    Nginx does not start on its own. To get Nginx running, type:
   &lt;code&gt;sudo systemctl start nginx&lt;/code&gt;
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--J-tkidD5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o99whtwn6osals4kb1uw.png" alt="image"&gt; &lt;/li&gt;
&lt;li&gt;Enable HTTP/HTTPS communication in your firewall. E.g. CentOS:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd –reload
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;    Create location for your SSL certificates close to NGINX config and put them there:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir /etc/nginx/ssl
mv fullchain.pem /etc/nginx/ssl/your.domain.crt
mv privatekey.pem /etc/nginx/ssl/your.domain.key
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;    Create new config file:
   &lt;code&gt;vim /etc/nginx/conf.d/secerts.your.domain.conf&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;    This part will redirect HTTP to HTTPS:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;server {
  listen 80;
   listen [::]:80;
   server_name secrets.your.domain;
   return 301 https://$host$request_uri;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;This part will execute proxy pass to the target URL:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; server {
       listen      443 ssl http2 default_server;
       listen      [::]:443 ssl http2 default_server;
       server_name secrets.your.domain;
       root        /usr/share/nginx/html;
       ssl_certificate "/etc/nginx/ssl/your.domain.crt";
       ssl_certificate_key "/etc/nginx/ssl/your.domain.key";
       ssl_session_cache shared:SSL:1m;
       ssl_session_timeout 10m;
       ssl_ciphers HIGH:!aNULL:!MD5;
       ssl_prefer_server_ciphers on;
       location / {
           proxy_pass https://some-service-secrets.azurewebsites.net;
       }
       error_page 404 /404.html;
       location = /404.html {
       }
       error_page 500 502 503 504 /50x.html;
       location = /50x.html {
       }
   }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;    Reload NGINX:
    &lt;code&gt;nginx -s reload&lt;/code&gt;
    or
    &lt;code&gt;systemctl restart nginx&lt;/code&gt;
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mRtzBwD6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dqvpi8eg75r4lq5kp7hq.png" alt="image"&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>azure</category>
      <category>appservice</category>
      <category>payasyougo</category>
    </item>
  </channel>
</rss>
