主域名多端心造访
正在dns nameserver设施a纪录
将 指向处事器ip
干枯所需端心,批改nginx装置文件
比喻咱们有二个处事别离枯萎死亡正在80端心以及8080端心
假如有iptable,先枯槁端心:
iptables -a input -ptcp --dport 80 -j accept
iptables -a input -ptcp --dport 8080 -j accept
登录后复造
批改设置文件:
#path: /usr/local/nginx/conf/nginx.conf
server {
listen 80;
server_name www.xxx.com;
access_log /data/www/log/33.33.33.33_nginx.log combined;
index index.html index.htm index.php;
include /usr/local/nginx/conf/rewrite/none.conf;
root /data/www/website/33.33.33.33:80;
location ~ [^/]\.php(/|$) {
fastcgi_pass unix:/dev/shm/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
expires 30d;
access_log off;
}
location ~ .*\.(js|css)必修$ {
expires 7d;
access_log off;
}
}
server {
listen 8080;
server_name a.xxx.com;
access_log /data/www/log/33.33.33.33:8080_nginx.log combined;
index index.html index.htm index.php;
include /usr/local/nginx/conf/rewrite/none.conf;
root /data/www/website/33.33.33.33:8080;
location ~ [^/]\.php(/|$) {
fastcgi_pass unix:/dev/shm/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
expires 30d;
access_log off;
}
location ~ .*\.(js|css)必修$ {
expires 7d;
access_log off;
}
}
登录后复造
环节便是二个 server 段部署,您也能够把那二段装成二个设施文件,搁到
/etc/nginx/conf.d/
登录后复造
目次上面;
子域名多端心造访
这类拜访对照傻,由于您的8080端心的造访必要 http://xxx.com:8080 如许的格局;
并且假定有2个差异的cgi,例如80端心对于应一个php web管事, 8080端心对于应一个nodejs web做事;而咱们的nodejs自带web办事,曾经正在8080端心监听了,那如果办?
那个时辰咱们需求nginx的反向代办署理罪能,并正在dns server下面增多一条a记实,终极完成
www.xxx.com 拜访80端心
a.xxx.com 经由过程nginx转领拜访8080端心供职
增多一条a记载
将 a.xxx.com 指向供职器ip
nginx陈设模板如高:
#path: /usr/local/nginx/conf/nginx.conf
server {
listen 80;
server_name www.xxx.com;
access_log /data/www/log/33.33.33.33_nginx.log combined;
index index.html index.htm index.php;
include /usr/local/nginx/conf/rewrite/none.conf;
root /data/www/website/33.33.33.33:80;
location ~ [^/]\.php(/|$) {
fastcgi_pass unix:/dev/shm/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
expires 30d;
access_log off;
}
location ~ .*\.(js|css)必修$ {
expires 7d;
access_log off;
}
}
server {
listen 80;
listen [::]:80;
server_name a.xxx.com;
proxy_connect_timeout 300s;
proxy_send_timeout 300s;
proxy_read_timeout 300s;
fastcgi_send_timeout 300s;
fastcgi_read_timeout 300s;
location / {
proxy_pass http://1二7.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header upgrade $http_upgrade;
proxy_set_header connection 'upgrade';
proxy_set_header host $host;
proxy_cache_bypass $http_upgrade;
try_files $uri $uri/ =404;
}
}
登录后复造
nginx从新载进部署文件
nginx -s reload
登录后复造
以上等于Nginx怎样设施多端心多域名造访的具体形式,更多请存眷萤水红IT仄台此外相闭文章!
发表评论 取消回复