我有一些网站具有域名和一些地址,这些地址应该可以与ip.ip.ip.ip/mah/wp-login.php
之类的ip一起使用。这是我的default.conf
配置:
server {
listen 80;
listen [::]:80;
error_log /var/log/nginx/phperror.log;
root /var/www/html/;
index index.htm index.html index.php wp-login.php display.php;
server_name localhost;
location / {
autoindex on;
try_files $uri $uri/ /index.php?q=$uri&$args;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php-fpm;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:8080;
}
location ~ /\.ht$ {
deny all;
}
}
server {
listen 80;
server_name django-site.com www.django-site.com;
error_log /var/www/html/igame/error.log;
client_max_body_size 20M;
location / {
proxy_pass http://127.0.0.1:8001;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Real-IP $remote_addr;
add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"';
}
location /static/ {
autoindex on;
alias /var/www/html/igame/static/;
}
location /media/ {
autoindex on;
alias /var/www/html/igame/media/;
}
}
server {
listen 80;
server_name word-press-site.com www.word-press-site.com;
error_log /var/www/html/ketab/error.log;
root /var/www/html/ketab;
index index.html index.htm index.php;
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php-fpm;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:8080;
}
}
如您所见,与php
兼容的网站被重定向到端口8080
上的apache。这就是我要处理的地址,例如ip.ip.ip.ip/mah/wp-login.php
。位于mah
的{{1}}操作系统
但是当我尝试它时,我发现django 404找不到错误,这意味着它正在作为/var/www/html/mah
域的第二个服务器块运行。
如何配置nginx,以便可以寻址到没有django-site.com
的文件夹?
我希望我能说清楚。