<?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: Norman</title>
    <description>The latest articles on DEV Community by Norman (@hkthirano).</description>
    <link>https://dev.to/hkthirano</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%2F1186557%2F6d231b84-a676-40e4-86c6-147e1bd516d0.png</url>
      <title>DEV Community: Norman</title>
      <link>https://dev.to/hkthirano</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hkthirano"/>
    <language>en</language>
    <item>
      <title>Hosting React with nginx+docker</title>
      <dc:creator>Norman</dc:creator>
      <pubDate>Thu, 07 Dec 2023 13:41:33 +0000</pubDate>
      <link>https://dev.to/hkthirano/hosting-react-with-nginxdocker-9e9</link>
      <guid>https://dev.to/hkthirano/hosting-react-with-nginxdocker-9e9</guid>
      <description>&lt;p&gt;Create sample app.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-react-app my-app
cd my-app
npm start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create Dockerfile.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FROM node:18-alpine

WORKDIR /react-docker-example/

COPY public/ /react-docker-example/public
COPY src/ /react-docker-example/src
COPY package.json /react-docker-example/

RUN npm install

CMD ["npm", "start"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Build and run docker image.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker image build -t my-app-image:latest .
docker run -dp 65535:3000 --name my-app-container my-app-image:latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can display app in a browser at the following URL.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;http://&amp;lt;your-ip&amp;gt;:65535&lt;/code&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Hosting index.html with HTTPS using Docker and Nginx</title>
      <dc:creator>Norman</dc:creator>
      <pubDate>Sat, 11 Nov 2023 02:26:45 +0000</pubDate>
      <link>https://dev.to/hkthirano/hosting-indexhtml-with-https-using-docker-and-nginx-121p</link>
      <guid>https://dev.to/hkthirano/hosting-indexhtml-with-https-using-docker-and-nginx-121p</guid>
      <description>&lt;p&gt;1) Pull nginx image&lt;br&gt;
&lt;code&gt;docker image pull nginx&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;2) Create nginx container&lt;br&gt;
&lt;code&gt;docker container run -d -p 443:443 --name mynginx nginx&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;3) Enter the container&lt;br&gt;
&lt;code&gt;docker container exec -it mynginx bash&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;4) Create the private key and certificate&lt;br&gt;
&lt;code&gt;mkdir /etc/nginx/ssl&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;private key&lt;br&gt;
&lt;code&gt;openssl genrsa -out /etc/nginx/ssl/server.key 2048&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Certificate Signing Request (CSR)&lt;br&gt;
you can skip through by pressing the Enter key for each prompt&lt;br&gt;
&lt;code&gt;openssl req -new -key /etc/nginx/ssl/server.key -out /etc/nginx/ssl/server.csr&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;SSL server certificate (CRT)&lt;br&gt;
&lt;code&gt;openssl x509 -days 3650 -req -signkey /etc/nginx/ssl/server.key -in /etc/nginx/ssl/server.csr -out /etc/nginx/ssl/server.crt&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;5) Edit the Nginx configuration file&lt;br&gt;
&lt;code&gt;vi /etc/nginx/conf.d/ssl.conf&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;server {
    listen 443 default ssl;
    root   /usr/share/nginx/html;
    index  index.html index.htm;
    ssl_certificate     /etc/nginx/ssl/server.crt;
    ssl_certificate_key /etc/nginx/ssl/server.key;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;6) Reload the Nginx configuration&lt;br&gt;
&lt;code&gt;service nginx reload&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;7) Access the following URL&lt;br&gt;
&lt;u&gt;&lt;a href="https://container-IP/"&gt;https://container-IP/&lt;/a&gt;&lt;/u&gt;&lt;/p&gt;

</description>
      <category>docker</category>
      <category>nginx</category>
      <category>web</category>
    </item>
  </channel>
</rss>
