我在windows上运行Nginx PHP MysqL和tomcat postresql(我知道它不是很好用的资源,我只是需要它们用于某些项目).
我需要一点Nginx配置的帮助.
我最终计划在端口80上运行Nginx,其中wiki.example.com和site.example.com是相同的IP.
但我想将site.example.com的请求转发到localhost:8080的tomcat,并且Nginx将为wiki.example.com提供服务.
我知道我的问题在于配置,只是因为我可以在控制台中看到错误;即使它们位于不同的服务器块中,我也无法设置两个“位置/”设置.这是我的配置,有谁知道如何解决它?
http {
include mime.types;
default_type application/octet-stream;
server {
listen 8080 default_server;
server_name _;
server_name_in_redirect off;
root www/html;
}
server {
listen wiki.example.com:8080;
server_name wiki.example.com;
location / {
#proxy_pass http://localhost:80/;
#proxy_set_header Host $http_host;
root www/wiki;
index index.html index.htm index.PHP;
}
location ~ .PHP${
root www/wiki;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.PHP;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
index index.PHP;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
server {
listen site.example.com:8080;
server_name site.example.com;
root www/html;
location / {
proxy_pass http://localhost:80/;
proxy_set_header Host $http_host;
root www/html;
index index.html index.htm index.PHP;
}
}
}
编辑:
非常感谢您的帮助.我根据你的指示编辑了配置,它主要工作!
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。