Nginx:两个虚拟主机

Nginx:两个虚拟主机,nginx,Nginx,一个是博客,另一个是网络应用,为他们使用两个虚拟主机和两个二级域名 blog.example.com webapp.example.com vitual.conf文件位于/etc/nginx/conf.d下,包括在nginx配置文件中,这里是virtual.conf ######################for blog############################## server { listen 80; serve

一个是博客,另一个是网络应用,为他们使用两个虚拟主机和两个二级域名

blog.example.com

webapp.example.com

vitual.conf文件位于/etc/nginx/conf.d下,包括在nginx配置文件中,这里是virtual.conf

 ######################for blog##############################
    server {
            listen  80;
            server_name  blog.example.cn;
            access_log  /www/access_blog  main;
            location / {
                root   /www/blog;
                index  index.php index.html index.htm;
            }
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   /usr/share/nginx/html;
            }
           # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
            location ~ \.php$ {
             fastcgi_pass   127.0.0.1:9000;
             fastcgi_index   index.php;
             fastcgi_param  SCRIPT_FILENAME   /www/blog/$fastcgi_script_name;
             include        fastcgi_params;
          }
            location ~ /.ht {
                deny  all;
            }
    }
    #######################for web app#######################
    server {
            listen  80;
            server_name webapp.example.com; 
            access_log  /www/access_webapp  main;
            location / {
                root   /www/webapp;
                index  index.php index.html index.htm;
            }
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   /usr/share/nginx/html;
            }
           # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
            location ~ \.php$ {
             fastcgi_pass   127.0.0.1:9000;
             fastcgi_index   index.php;
             fastcgi_param  SCRIPT_FILENAME   /www/oclass/$fastcgi_script_name;
             include        fastcgi_params;
          }
            location ~ /.ht {
                deny  all;
            }
    }
web应用程序可以正常服务,但当输入的地址时,总是转到

似乎是nginx把请求转发到了8888端口,所以我把blog的服务器改为监听8888端口

#######################for web app#######################
server {
        listen  8888;

然后它工作了,nginx可以正常服务于blog(顺便说一下direction/www的权限模式是755),但是如何解决这个问题,因为blog服务器和web应用都可以监听80

你是说https
https
?因为您只定义了
http
服务器块。上面的配置没有重定向到8888端口,这表明博客应用程序正在自己完成。非常感谢!你是说https
https
?因为您只定义了
http
服务器块。上面的配置没有重定向到8888端口,这表明博客应用程序正在自己完成。非常感谢!