概述
nginx配置文件:
#user nobody;
worker_processes 4;
error_log logs/error.log;
error_log logs/error.log notice;
error_log logs/error.log info;
pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log logs/access.log main;
sendfile on;
tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 90;
#gzip on;
server {
listen 192.168.88.134:8080;
server_name 192.168.88.134;
#charset koi8-r;
access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm index.php;
#autoindex on;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ .php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ .php$ {
root html;
fastcgi_pass 127.0.0.1:9999;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}
location ~ .cgi$ { //配置cgi程序
root html;
fastcgi_pass 127.0.0.1:7000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /.ht {
# deny all;
#}
}
}
root@ubuntu:/etc/network# cat interfaces
auto eth0
iface eth0 inet static
address 192.168.88.134
netmask 255.255.255.0
gateway 192.168.88.1
auto eth0:1
iface eth0:1 inet static
address 192.168.88.135
netmask 255.255.255.0
up route add -host 192.168.88.135 dev eth0:1
auto eth0:2
iface eth0:2 inet static
address 192.168.88.136
netmask 255.255.255.0
up route add -host 192.168.88.136 dev eth0:2
重启nginx及spawn-fcgi程序
重启网络:/etc/init.d/networking restart
http://192.168.88.136:8080/test.cgi
http://192.168.88.135:8080/test.cgi
http://192.168.88.134:8080/test.cgi
均能正常访问了
最后
以上就是甜美白猫为你收集整理的nginx配置多个虚拟ip访问的全部内容,希望文章能够帮你解决nginx配置多个虚拟ip访问所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复