httpd 发表于 2025-1-6 21:20:36

CHEVERETO在Nginx環境的Nginx虛擬主機中有一段僞靜態無法添加

<div class="blockcode"><div id="code_J8G"><ol><li># Disable access to sensitive application files<br /><li>location ~* (app|content|lib)/.*\.(po|php|lock|sql)$ {<br /><li>return 404;<br /><li>}<br /><li>location ~* composer\.json|composer\.lock|.gitignore$ {<br /><li>return 404;<br /><li>}<br /><li>location ~* /\.ht {<br /><li>return 404;<br /><li>}<br /><li><br /><li># Image not found replacement<br /><li>location ~* \.(jpe?g|png|gif|webp)$ {<br /><li>log_not_found off;<br /><li>error_page 404 /content/images/system/default/404.gif;<br /><li>}<br /><li><br /><li># CORS header (avoids font rendering issues)<br /><li>location ~* \.(ttf|ttc|otf|eot|woff|woff2|font.css|css|js)$ {<br /><li>add_header Access-Control-Allow-Origin &quot;*&quot;;<br /><li>}<br /><li><br /><li># PHP front controller<br /><li>location / {<br /><li>index index.php;<br /><li>try_files $uri $uri/ /index.php$is_args$query_string;<br /><li>}<br /><li><br /><li># Single PHP-entrypoint (disables direct access to .php files)<br /><li>location ~* \.php${<br /><li>internal;<br /><li>include snippets/fastcgi-php.conf;<br /><li>fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;<br /><li>}</ol></div><em onclick="copycode($('code_J8G'));">复制代码</em></div><br />
<br />
就是這一段中的<br /><div class="blockcode"><div id="code_ebG"><ol><li># Single PHP-entrypoint (disables direct access to .php files)<br /><li>location ~* \.php${<br /><li>internal;<br /><li>include snippets/fastcgi-php.conf;<br /><li>fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;<br /><li>}</ol></div><em onclick="copycode($('code_ebG'));">复制代码</em></div><br />
這段添加進去Nginx報錯,無法啓動

NodeLoc 发表于 2025-1-6 21:22:14

删掉就好了 这一段没用

httpd 发表于 2025-1-6 21:24:03

<div class="quote"><blockquote><font size="2"><a href="https://hostloc.com/forum.php?mod=redirect&goto=findpost&pid=16173582&ptid=1380692" target="_blank"><font color="#999999">NodeLoc 发表于 2025-1-6 21:22</font></a></font><br />
删掉就好了 这一段没用</blockquote></div><br />
真的嗎?我看注釋寫的作用是禁用直接訪問php文件

NodeLoc 发表于 2025-1-6 21:22:00

PHP文件直接访问也没用啊 没用的

ncsccc 发表于 2025-1-6 21:28:58

<div class="blockcode"><div id="code_Jif"><ol><li>location / {<br /><li>if (-f $request_filename/index.html){<br /><li>rewrite (.*) $1/index.html break;<br /><li>}<br /><li>if (-f $request_filename/index.php){<br /><li>rewrite (.*) $1/index.php;<br /><li>}<br /><li>if (!-f $request_filename){<br /><li>rewrite (.*) /index.php;<br /><li>}<br /><li>try_files $uri $uri/ /api.php;<br /><li>}<br /><li>location /admin {<br /><li>try_files $uri /admin/index.php?$args;<br /><li>}</ol></div><em onclick="copycode($('code_Jif'));">复制代码</em></div><br />
<br />
<br />
我的

httpd 发表于 2025-1-6 21:29:12

<div class="quote"><blockquote><font size="2"><a href="https://hostloc.com/forum.php?mod=redirect&goto=findpost&pid=16173597&ptid=1380692" target="_blank"><font color="#999999">ncsccc 发表于 2025-1-6 21:29</font></a></font><br />
我的</blockquote></div><br />
是V3.20.20嗎

httpd 发表于 2025-1-6 21:33:44

<div class="quote"><blockquote><font size="2"><a href="https://hostloc.com/forum.php?mod=redirect&goto=findpost&pid=16173596&ptid=1380692" target="_blank"><font color="#999999">NodeLoc 发表于 2025-1-6 21:28</font></a></font><br />
PHP文件直接访问也没用啊 没用的</blockquote></div><br />
哦哦

ncsccc 发表于 2025-1-6 21:29:00

<div class="quote"><blockquote><font size="2"><a href="https://hostloc.com/forum.php?mod=redirect&goto=findpost&pid=16173605&ptid=1380692" target="_blank"><font color="#999999">httpd 发表于 2025-1-6 21:33</font></a></font><br />
是V3.20.20嗎</blockquote></div><br />
是的

httpd 发表于 2025-1-6 21:35:12

<div class="quote"><blockquote><font size="2"><a href="https://hostloc.com/forum.php?mod=redirect&goto=findpost&pid=16173609&ptid=1380692" target="_blank"><font color="#999999">ncsccc 发表于 2025-1-6 21:36</font></a></font><br />
是的</blockquote></div><br />
好簡潔<img id="aimg_sI9uW" onclick="zoom(this, this.src, 0, 0, 0)" class="zoom" src="http://1" onmouseover="img_onmouseoverfunc(this)" onload="thumbImg(this)" border="0" alt="" />
页: [1]
查看完整版本: CHEVERETO在Nginx環境的Nginx虛擬主機中有一段僞靜態無法添加