<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:series="https://publishpress.com/"
	>

<channel>
	<title>ngrok Archives - Tomoshare</title>
	<atom:link href="https://blog.tomosia.com.vn/tag/ngrok/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.tomosia.com.vn/tag/ngrok/</link>
	<description>Kênh chia sẻ kiến thức Tomosia Việt Nam</description>
	<lastBuildDate>Tue, 31 Oct 2023 02:07:04 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://blog.tomosia.com.vn/wp-content/uploads/2023/09/cropped-icon-32x32.png</url>
	<title>ngrok Archives - Tomoshare</title>
	<link>https://blog.tomosia.com.vn/tag/ngrok/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Ngrok And Using Ngrok for Rails Application</title>
		<link>https://blog.tomosia.com.vn/ngrok-and-using-ngrok-for-rails-application/</link>
					<comments>https://blog.tomosia.com.vn/ngrok-and-using-ngrok-for-rails-application/#comments</comments>
		
		<dc:creator><![CDATA[Hổ Nguyễn]]></dc:creator>
		<pubDate>Tue, 31 Oct 2023 02:07:03 +0000</pubDate>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[ngrok]]></category>
		<guid isPermaLink="false">https://blog.tomosia.com.vn/?p=1588</guid>

					<description><![CDATA[<p>Ngrok là gì? Install Ngrok: Trên MacOS, sử dụng HomeBrew: Trên Linux, sử dụng Apt: Trên Windows, sử&#8230;</p>
<p>The post <a href="https://blog.tomosia.com.vn/ngrok-and-using-ngrok-for-rails-application/">Ngrok And Using Ngrok for Rails Application</a> appeared first on <a href="https://blog.tomosia.com.vn">Tomoshare</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 id="ngrok-la-gi" class="wp-block-heading has-medium-font-size"><strong>Ngrok là gì?</strong></h2>



<ul class="wp-block-list">
<li>Ngrok là một ứng dụng cho phép bạn truy cập từ bên ngoài internet đến hệ thống nội bộ (localhost) thông qua đường hầm an toàn được mã hoá mà ai cũng có thể truy cập được thông qua custom domain của Ngrok.</li>
</ul>



<ul class="wp-block-list">
<li>Trong một ngày đẹp trời khách hàng đang cần một demo gấp mà chưa kịp xây dựng môi trường staging để kiểm thử sản phẩm, việc sử dụng Ngrok là một giải pháp tuyệt vời để giải quyết vấn đề này. </li>



<li>Bạn có thể chạy ứng dụng của mình trên máy tính cá nhân và sử dụng Ngrok để tạo ra một đường link truy cập từ xa. Khách hàng có thể truy cập vào sản phẩm của bạn ngay lập tức, mà không cần phải chờ đợi xây dựng môi trường staging. Điều này giúp tiết kiệm thời gian và giúp bạn đáp ứng nhanh chóng yêu cầu của khách hàng.</li>
</ul>



<h2 id="install-ngrok" class="wp-block-heading has-medium-font-size" style="font-style:normal;font-weight:500"><strong>Install Ngrok</strong>:</h2>



<p>Trên MacOS, sử dụng HomeBrew:</p>



<pre class="wp-block-code"><code><code>brew install ngrok/ngrok/ngrok</code></code></pre>



<p>Trên Linux, sử dụng Apt:</p>



<pre class="wp-block-code"><code>  $ sudo tee /etc/apt/trusted.gpg.d/ngrok.asc &gt;/dev/null &amp;&amp; \\
  $ echo "deb &lt;https://ngrok-agent.s3.amazonaws.com&gt; buster main" | \\
  $ sudo tee /etc/apt/sources.list.d/ngrok.list &amp;&amp; \\
  $ sudo apt update &amp;&amp; sudo apt install ngrok\\
</code></pre>



<p>Trên Windows, sử dụng&nbsp;<a href="https://chocolatey.org/">Chocolatey</a>:</p>



<pre class="wp-block-code"><code><code>choco install ngrok</code></code></pre>



<p><strong>Unzip to install:</strong> Trên Linux hoặc Mac OS X, bạn có thể giải nén ngrok từ terminal bằng lệnh sau. Trên Windows, chỉ cần nhấp đúp vào ngrok.zip để giải nén nó.</p>



<pre class="wp-block-code"><code>$ unzip /path/to/ngrok.zip</code></pre>



<p><strong>Tạo tài khoản trên <a href="https://dashboard.ngrok.com/">ngrok dashboard</a>:</strong></p>



<figure class="wp-block-image size-large"><img fetchpriority="high" decoding="async" width="1024" height="582" src="http://blog.tomosia.com.vn/wp-content/uploads/2023/10/Screenshot-2023-10-25-at-3.22.20-PM-2-1024x582.png" alt="" class="wp-image-1594" srcset="https://blog.tomosia.com.vn/wp-content/uploads/2023/10/Screenshot-2023-10-25-at-3.22.20-PM-2-1024x582.png 1024w, https://blog.tomosia.com.vn/wp-content/uploads/2023/10/Screenshot-2023-10-25-at-3.22.20-PM-2-300x170.png 300w, https://blog.tomosia.com.vn/wp-content/uploads/2023/10/Screenshot-2023-10-25-at-3.22.20-PM-2-768x436.png 768w, https://blog.tomosia.com.vn/wp-content/uploads/2023/10/Screenshot-2023-10-25-at-3.22.20-PM-2-1536x873.png 1536w, https://blog.tomosia.com.vn/wp-content/uploads/2023/10/Screenshot-2023-10-25-at-3.22.20-PM-2-2048x1163.png 2048w, https://blog.tomosia.com.vn/wp-content/uploads/2023/10/Screenshot-2023-10-25-at-3.22.20-PM-2-380x216.png 380w, https://blog.tomosia.com.vn/wp-content/uploads/2023/10/Screenshot-2023-10-25-at-3.22.20-PM-2-800x454.png 800w, https://blog.tomosia.com.vn/wp-content/uploads/2023/10/Screenshot-2023-10-25-at-3.22.20-PM-2-1160x659.png 1160w, https://blog.tomosia.com.vn/wp-content/uploads/2023/10/Screenshot-2023-10-25-at-3.22.20-PM-2.png 2880w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p><strong>Kết nối với tài khoản của bạn:</strong> </p>



<p>Ở đây, chúng ta sẽ cần authtoken từ bước trước. Authtoken là điều mà agent sử dụng để đăng nhập vào tài khoản của bạn khi tạo một đường hầm. Chạy dòng lệnh sau trong dòng lệnh.</p>



<pre class="wp-block-code"><code><code>ngrok config add-authtoken TOKEN</code></code></pre>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="582" src="http://blog.tomosia.com.vn/wp-content/uploads/2023/10/Screenshot-2023-10-25-at-3.27.27-PM-2-1024x582.png" alt="" class="wp-image-1597" srcset="https://blog.tomosia.com.vn/wp-content/uploads/2023/10/Screenshot-2023-10-25-at-3.27.27-PM-2-1024x582.png 1024w, https://blog.tomosia.com.vn/wp-content/uploads/2023/10/Screenshot-2023-10-25-at-3.27.27-PM-2-300x171.png 300w, https://blog.tomosia.com.vn/wp-content/uploads/2023/10/Screenshot-2023-10-25-at-3.27.27-PM-2-768x437.png 768w, https://blog.tomosia.com.vn/wp-content/uploads/2023/10/Screenshot-2023-10-25-at-3.27.27-PM-2-1536x874.png 1536w, https://blog.tomosia.com.vn/wp-content/uploads/2023/10/Screenshot-2023-10-25-at-3.27.27-PM-2-2048x1165.png 2048w, https://blog.tomosia.com.vn/wp-content/uploads/2023/10/Screenshot-2023-10-25-at-3.27.27-PM-2-380x216.png 380w, https://blog.tomosia.com.vn/wp-content/uploads/2023/10/Screenshot-2023-10-25-at-3.27.27-PM-2-800x455.png 800w, https://blog.tomosia.com.vn/wp-content/uploads/2023/10/Screenshot-2023-10-25-at-3.27.27-PM-2-1160x660.png 1160w, https://blog.tomosia.com.vn/wp-content/uploads/2023/10/Screenshot-2023-10-25-at-3.27.27-PM-2.png 2880w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p><strong>Config Ngrok trong Rails development enviroment</strong>: </p>



<ul class="wp-block-list">
<li>Trong ứng dụng của bạn, bạn sẽ có một file <code>config/environments/development.rb</code>. Tệp này cho Rails biết cách cấu hình môi trường phát triển.</li>



<li> <span style="font-size: revert; color: initial; font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, &quot;Noto Sans&quot;, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;, &quot;Noto Color Emoji&quot;;">Ở đây chúng ta sẽ cần thêm một dòng: </span></li>
</ul>



<pre class="wp-block-code"><code><code style="color: initial;">config.hosts &lt;&lt; /.*\\.ngrok-free.app/</code></code></pre>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="762" src="http://blog.tomosia.com.vn/wp-content/uploads/2023/10/Screenshot-2023-10-25-at-3.33.33-PM-1-1024x762.png" alt="" class="wp-image-1596" srcset="https://blog.tomosia.com.vn/wp-content/uploads/2023/10/Screenshot-2023-10-25-at-3.33.33-PM-1-1024x762.png 1024w, https://blog.tomosia.com.vn/wp-content/uploads/2023/10/Screenshot-2023-10-25-at-3.33.33-PM-1-300x223.png 300w, https://blog.tomosia.com.vn/wp-content/uploads/2023/10/Screenshot-2023-10-25-at-3.33.33-PM-1-768x572.png 768w, https://blog.tomosia.com.vn/wp-content/uploads/2023/10/Screenshot-2023-10-25-at-3.33.33-PM-1-1536x1143.png 1536w, https://blog.tomosia.com.vn/wp-content/uploads/2023/10/Screenshot-2023-10-25-at-3.33.33-PM-1-2048x1524.png 2048w, https://blog.tomosia.com.vn/wp-content/uploads/2023/10/Screenshot-2023-10-25-at-3.33.33-PM-1-380x283.png 380w, https://blog.tomosia.com.vn/wp-content/uploads/2023/10/Screenshot-2023-10-25-at-3.33.33-PM-1-800x595.png 800w, https://blog.tomosia.com.vn/wp-content/uploads/2023/10/Screenshot-2023-10-25-at-3.33.33-PM-1-1160x863.png 1160w, https://blog.tomosia.com.vn/wp-content/uploads/2023/10/Screenshot-2023-10-25-at-3.33.33-PM-1.png 2252w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>Bây giờ chúng ta có thể chạy máy chủ rails của chúng ta: <code>rails s</code> Và connect đến locahost thông qua ngrok bằng câu lệnh sau: <code>ngrok http &lt;port&gt;</code>  </p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="624" src="http://blog.tomosia.com.vn/wp-content/uploads/2023/10/Screenshot-2023-10-26-at-9.27.42-AM-1024x624.png" alt="" class="wp-image-1599" srcset="https://blog.tomosia.com.vn/wp-content/uploads/2023/10/Screenshot-2023-10-26-at-9.27.42-AM-1024x624.png 1024w, https://blog.tomosia.com.vn/wp-content/uploads/2023/10/Screenshot-2023-10-26-at-9.27.42-AM-300x183.png 300w, https://blog.tomosia.com.vn/wp-content/uploads/2023/10/Screenshot-2023-10-26-at-9.27.42-AM-768x468.png 768w, https://blog.tomosia.com.vn/wp-content/uploads/2023/10/Screenshot-2023-10-26-at-9.27.42-AM-1536x935.png 1536w, https://blog.tomosia.com.vn/wp-content/uploads/2023/10/Screenshot-2023-10-26-at-9.27.42-AM-2048x1247.png 2048w, https://blog.tomosia.com.vn/wp-content/uploads/2023/10/Screenshot-2023-10-26-at-9.27.42-AM-380x231.png 380w, https://blog.tomosia.com.vn/wp-content/uploads/2023/10/Screenshot-2023-10-26-at-9.27.42-AM-800x487.png 800w, https://blog.tomosia.com.vn/wp-content/uploads/2023/10/Screenshot-2023-10-26-at-9.27.42-AM-1160x706.png 1160w, https://blog.tomosia.com.vn/wp-content/uploads/2023/10/Screenshot-2023-10-26-at-9.27.42-AM.png 2880w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<pre class="wp-block-preformatted">Lưu ý: Thay <code>&lt;port&gt;</code> bằng địa chỉ localhost mà bạn đã cấu hình trong backend. Rails mặc định là 3000, nhưng bạn nên sử dụng bất cứ cái nào bạn muốn.</pre>



<p>Như vậy là bạn đã connect thành công và có thể truy cập đến địa chỉ của ngrok <code>https://9b7c-118-69-55-83.ngrok-free.app</code> để test ở trình duyệt như sau:</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="640" src="http://blog.tomosia.com.vn/wp-content/uploads/2023/10/Screenshot-2023-10-26-at-9.28.14-AM-1024x640.png" alt="" class="wp-image-1600" srcset="https://blog.tomosia.com.vn/wp-content/uploads/2023/10/Screenshot-2023-10-26-at-9.28.14-AM-1024x640.png 1024w, https://blog.tomosia.com.vn/wp-content/uploads/2023/10/Screenshot-2023-10-26-at-9.28.14-AM-300x188.png 300w, https://blog.tomosia.com.vn/wp-content/uploads/2023/10/Screenshot-2023-10-26-at-9.28.14-AM-768x480.png 768w, https://blog.tomosia.com.vn/wp-content/uploads/2023/10/Screenshot-2023-10-26-at-9.28.14-AM-1536x961.png 1536w, https://blog.tomosia.com.vn/wp-content/uploads/2023/10/Screenshot-2023-10-26-at-9.28.14-AM-2048x1281.png 2048w, https://blog.tomosia.com.vn/wp-content/uploads/2023/10/Screenshot-2023-10-26-at-9.28.14-AM-380x238.png 380w, https://blog.tomosia.com.vn/wp-content/uploads/2023/10/Screenshot-2023-10-26-at-9.28.14-AM-800x500.png 800w, https://blog.tomosia.com.vn/wp-content/uploads/2023/10/Screenshot-2023-10-26-at-9.28.14-AM-1160x725.png 1160w, https://blog.tomosia.com.vn/wp-content/uploads/2023/10/Screenshot-2023-10-26-at-9.28.14-AM.png 2696w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p><em>Cảm ơn bạn đã đọc bài viết này về tính năng&nbsp;<code>ngrok</code> và cách sử dụng trong rails&nbsp;. Hy vọng rằng bạn đã tìm thấy thông tin hữu ích và có thêm kiến thức về cách sử dụng tính năng này để tạo ra đường hầm kết nối từ localhost đến internet trong ứng dụng của mình</em>. Cảm ơn các bạn đã ủng hộ.</p>
<p>The post <a href="https://blog.tomosia.com.vn/ngrok-and-using-ngrok-for-rails-application/">Ngrok And Using Ngrok for Rails Application</a> appeared first on <a href="https://blog.tomosia.com.vn">Tomoshare</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.tomosia.com.vn/ngrok-and-using-ngrok-for-rails-application/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
	</channel>
</rss>
