<?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/"
	>

<channel>
	<title>靜態文件 | SDT 攻城獅區</title>
	<atom:link href="https://sdt.hameba.tw/tag/%E9%9D%9C%E6%85%8B%E6%96%87%E4%BB%B6/feed/" rel="self" type="application/rss+xml" />
	<link>https://sdt.hameba.tw</link>
	<description>由Steven, Der, Ted 三位高級打字員所組成，是三位工程師(攻城獅)所維護的技術分享平台，或許偶爾會分享一些日常，有任何問題或是錯誤的部分，歡迎留言告訴我們！</description>
	<lastBuildDate>Thu, 19 Dec 2019 22:16:58 +0800</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.3</generator>

<image>
	<url>https://sdt.hameba.tw/wp-content/uploads/2020/02/hameba_favicon-150x150.png</url>
	<title>靜態文件 | SDT 攻城獅區</title>
	<link>https://sdt.hameba.tw</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Nginx 訪問靜態文件</title>
		<link>https://sdt.hameba.tw/337/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=nginx-%25e8%25a8%25aa%25e5%2595%258f%25e9%259d%259c%25e6%2585%258b%25e6%2596%2587%25e4%25bb%25b6</link>
				<comments>https://sdt.hameba.tw/337/#respond</comments>
				<pubDate>Tue, 17 Dec 2019 13:35:29 +0000</pubDate>
		<dc:creator><![CDATA[Hsu Steven]]></dc:creator>
				<category><![CDATA[System]]></category>
		<category><![CDATA[location]]></category>
		<category><![CDATA[Nginx]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[靜態文件]]></category>

		<guid isPermaLink="false">https://sdt.hameba.tw/?p=337</guid>
				<description><![CDATA[<p>如何設定nginx，訪問靜態文件？ 因為google adsense 需要在網域上訪問 ads.txt檔案，  &#8230; </p>
<p class="link-more"><a href="https://sdt.hameba.tw/337/" class="more-link">閱讀全文<span class="screen-reader-text">〈Nginx 訪問靜態文件〉</span></a></p>
The post <a href="https://sdt.hameba.tw/337/">Nginx 訪問靜態文件</a> first appeared on <a href="https://sdt.hameba.tw">SDT 攻城獅區</a>.]]></description>
								<content:encoded><![CDATA[<p>如何設定nginx，訪問靜態文件？</p>
<p>因為google adsense 需要在網域上訪問 ads.txt檔案，</p>
<p><span id="more-337"></span></p>
<p>剛好有找到一些方法提供給大家，</p>
<ul>
<li>按目錄匹配 server塊內添加如下內容：</li>
</ul>
<p></p><pre class="crayon-plain-tag">server {
    .
    location ^~ /jsonfolder/ {
        root /home/www/;
    }
    .
}</pre><p>如果使用post方式將無法正確返回，需要修改nginx的源碼src/http/modules/ngx_http_static_module.c</p>
<p>移除以下內容</p><pre class="crayon-plain-tag">if (r-&gt;method &amp; NGX_HTTP_POST) {
    return NGX_HTTP_NOT_ALLOWED;
}</pre><p>執行make命令重新編譯，執行cp objs/nginx /usr/local/nginx/sbin/nginx，將objs目錄下生成nginx命令拷貝到nginx安裝目錄sbin目錄下，重啟即可。(此方法未驗證)</p>
<ul>
<li>按文件後綴匹配</li>
</ul>
<p></p><pre class="crayon-plain-tag">server {
    .
    location ~ \.(txt|json)$ {
        root /home/www/;
    }
    .
}</pre><p>匹配txt和json的文件就會被顯示出來</p>
<p>Reference</p>
<p><a href="https://blog.csdn.net/ocean20/article/details/80738798">https://blog.csdn.net/ocean20/article/details/80738798</a></p>The post <a href="https://sdt.hameba.tw/337/">Nginx 訪問靜態文件</a> first appeared on <a href="https://sdt.hameba.tw">SDT 攻城獅區</a>.]]></content:encoded>
							<wfw:commentRss>https://sdt.hameba.tw/337/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
							</item>
	</channel>
</rss>
