Nginx子域名配置

extends:http://blog.csdn.net/xiaoping0915/article/details/53899465 ,http://www.myhack58.com/Article/48/66/2012/34999.htm?spm=5176.100239.blogcont48640.5.jM0gSjphp

 

 

 

在阿里雲服務器的域名解析裏添加你要增長的子域名主機記錄html

 

而後在centos 的Nginx 配置中,增長子域名解析nginx

若是你解析的是本地IP端口地址centos

server { 

listen       80; 

server_name  B.ABC.com; 

location / { 
proxy_pass http://localhost:4321; 
//設置主機頭真實IP地址的用戶避免得到爲代理服務器的地址
proxy_set_header   Host    $host; 

proxy_set_header   X-Real-IP   $remote_addr; 

proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for; 

    } 

} 

若是你解析的是目錄網頁服務器

#MY CONFIG START
server
{
listen   80;
server_name  qq.com;
  root   /usr/share/nginx/html;
    index  index.php index.html index.htm;
    location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
}
}
#先配置的是qq.com,相信我有配置這個的必要性,location裏面的是爲了讓咱們的Nginx服務器知道.php文件要去找php解釋器執行,不配置可能會出現訪問即下載文件的現象
#不要問我爲何,我是抄上面那個默認的server的,錯不了,手動滑稽
server
{
    listen   80;
    server_name   blog.qq.com;
    root   /usr/share/nginx/html/blog;
    index  index.php index.html index.htm;
    location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
}
}
#MY CONFIG END

 

 

centos下使用iptables開放22,80,3306端口的方法tcp

 

vi /etc/sysconfig/iptables 
-A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT(容許80端口經過防火牆) 
-A INPUT -m state –state NEW -m tcp -p tcp –dport 3306 -j ACCEPT(容許3306端口經過防火牆) 
特別提示:不少網友把這兩條規則添加到防火牆配置的最後一行,致使防火牆啓動失敗,正確的應該是添加到默認的22端口這條規則的下面

添加好以後防火牆規則以下所示:
###################################### 
# Firewall configuration written by system-config-firewall 
# Manual customization of this file is not recommended. 
*filter 
:INPUT ACCEPT [0:0] 
:FORWARD ACCEPT [0:0] 
:OUTPUT ACCEPT [0:0] 
-A INPUT -m state –state ESTABLISHED,RELATED -j ACCEPT 
-A INPUT -p icmp -j ACCEPT 
-A INPUT -i lo -j ACCEPT 
-A INPUT -m state –state NEW -m tcp -p tcp –dport 22 -j ACCEPT 
-A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT 
-A INPUT -m state –state NEW -m tcp -p tcp –dport 3306 -j ACCEPT 
-A INPUT -j REJECT –reject-with icmp-host-prohibited 
-A FORWARD -j REJECT –reject-with icmp-host-prohibited 
COMMIT 
#####################################
/etc/init.d/iptables restart  
     #最後重啓防火牆使配置生效

 

 

使用http://tool.chinaz.com/port/來檢測是否開放成功this

相關文章
相關標籤/搜索