我们可以在 Nginx 位置配置 txt 文件吗
Can We Configure txt file in Nginx Locaton
我有服务器,其中部署了不同类型的项目。 php 中的一些项目和 jboss java war 文件中的一些项目。所以我在这一层使用 nginx 它在 configure
之后工作正常
用于 Php 项目
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
location ~ ^/(images|javascript|js|css|flash|media|static)/ {
root html/static;
expires 30d;
}
location ~ attendance/(js|css|images)/ {
# root html;
expires 30d;
}
对于 Java 项目
server {
listen 80;
server_name ncmmi02;
#charset koi8-r;
access_log /mnt/vol1/nginx_logs/host.access.log;
location / {
root html;
access_log off;
proxy_pass http://10.20.9.13:9090;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_redirect off;
}
对于 java 项目 运行 我有使用示例。com/abc(abc war 文件)
和 php 我使用示例的项目。com/attendance
现在我想将 txt 文件显示为示例数据。com/rom.txt
但此时包含不在浏览器中显示
在 *.php 一个
正下方添加此位置
location ~ *\.txt$ {
root /path/to/your/root;
}
我有服务器,其中部署了不同类型的项目。 php 中的一些项目和 jboss java war 文件中的一些项目。所以我在这一层使用 nginx 它在 configure
之后工作正常用于 Php 项目
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
location ~ ^/(images|javascript|js|css|flash|media|static)/ {
root html/static;
expires 30d;
}
location ~ attendance/(js|css|images)/ {
# root html;
expires 30d;
}
对于 Java 项目
server {
listen 80;
server_name ncmmi02;
#charset koi8-r;
access_log /mnt/vol1/nginx_logs/host.access.log;
location / {
root html;
access_log off;
proxy_pass http://10.20.9.13:9090;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_redirect off;
}
对于 java 项目 运行 我有使用示例。com/abc(abc war 文件) 和 php 我使用示例的项目。com/attendance
现在我想将 txt 文件显示为示例数据。com/rom.txt 但此时包含不在浏览器中显示
在 *.php 一个
正下方添加此位置location ~ *\.txt$ {
root /path/to/your/root;
}