nginx 다 중 포트 다 중 도 메 인 이름 접근 설정

7519 단어 nginx
링크 ux 다 중 포트 다 중 도 메 인 설정
반년 을 조정 하여 마침내 해결 하 였 는데, 무슨 문제 인지 모르겠다. 하 자!!
마지막 으로 원인 을 발 견 했 습 니 다. (. conf 부품 파일 의 형식 이 정확 하지 않 습 니 다. win 과 Liux 는 차이 가 있 습 니 다. 안전 을 위해 서 입 니까? 아니면 원래 conf 파일 을 복사 해서 고 치 는 것 입 니까?) 1. 방화벽 을 먼저 설정 합 니 다.
두 가지 방법 이 있 습 니 다. 하 나 는 아래 와 같이 직접 명령 행 을 두 드 리 는 것 입 니 다. 그리고 etc 아래 의 파일 을 수정 하 는 것 입 니 다. 마지막 으로 저장 하고 방화벽 을 다시 시작 하 는 것 을 기억 하 세 요.
방화벽 열기:
/sbin/iptables -I INPUT -p tcp --dport 1010 -j ACCEPT
/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT 
/sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT 
/sbin/iptables -I INPUT -p tcp --dport 1015 -j ACCEPT 
#  
/etc/rc.d/init.d/iptables save
#  
/etc/init.d/iptables restart  
#  
vi /etc/sysconfig/iptables
2、 hots, , hots :#192.168.0.38    demo38.com192.168.0.26    test80.com192.168.0.26    test1010.com192.168.0.26    app.test1010.com

, , IP, !!

IP , 。

3 3、 nginx.conf , :vi /usr/local/nginx/conf/nginx.conf , server{# code, }include vhost/*.conf;# , vhost/ .conf , server{} , vhost , test80.conf,test1010.conf , 2 ,1 ,1 ,
#test80.conf    :
server {  
    listen 80;  
    server_name test80.com;  
    location / { 
      root  /home/wwwroot/default/demo;
      index index.html index.htm;  
    }
} 

사실 위의 글 씨 는 좋 지 않 습 니 다. PHP 를 설정 할 때 오류 가 발생 할 수 있 기 때문에 추천 하 는 방법 은 바깥 의 큰 괄호 를 제거 하 는 것 입 니 다. 즉,:
local / {} 삭제
server {  
    listen 80;  
    server_name test80.com;  
      root  /home/wwwroot/default/demo;
      index index.html index.htm;  
} 

본문 마지막 에 파일 을 정확하게 설정 합 니 다.
#test1010.conf  :
server {
        listen       1010;
        server_name  test1010.com;


        index index.html index.htm index.php;
        root /home/wwwroot/default/demo;


        #charset koi8-r;


        #access_log  logs/host.access.log  main;



        #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$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            #fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            #include        fastcgi_params;
            include fastcgi.conf;
        }


        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }
server {
        listen       1010;
        server_name  app.test1010.com;

        index index.html index.htm index.php;
        root /home/wwwroot/default2;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;
	

        #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$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            #fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            #include        fastcgi_params;
            include fastcgi.conf;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }

올 바른 프로필:
b.1015.com.conf
server
	{
		listen       1015;
		server_name b.1015.com;
		index index.html index.htm index.php;
		root  /home/wwwroot/default/b;

		location ~ .*\.(php|php5)?$
			{
				try_files $uri =404;
				fastcgi_pass  unix:/tmp/php-cgi.sock;
				fastcgi_index index.php;
				include fcgi.conf;
			}

		location /status {
			stub_status on;
			access_log   off;
		}

		location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
			{
				expires      30d;
			}

		location ~ .*\.(js|css)?$
			{
				expires      12h;
			}

		access_log  /home/wwwlogs/access.log  access;
	}

nginx.conf
user  www www;

worker_processes 1;

error_log  /home/wwwlogs/nginx_error.log  crit;

pid        /usr/local/nginx/logs/nginx.pid;

#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200;

events
	{
		use epoll;
		worker_connections 51200;
	}

http
	{
		include       mime.types;
		default_type  application/octet-stream;

		server_names_hash_bucket_size 128;
		client_header_buffer_size 32k;
		large_client_header_buffers 4 32k;
		client_max_body_size 50m;

		sendfile on;
		tcp_nopush     on;

		keepalive_timeout 60;

		tcp_nodelay on;

		fastcgi_connect_timeout 300;
		fastcgi_send_timeout 300;
		fastcgi_read_timeout 300;
		fastcgi_buffer_size 64k;
		fastcgi_buffers 4 64k;
		fastcgi_busy_buffers_size 128k;
		fastcgi_temp_file_write_size 256k;

		gzip on;
		gzip_min_length  1k;
		gzip_buffers     4 16k;
		gzip_http_version 1.0;
		gzip_comp_level 2;
		gzip_types       text/plain application/x-javascript text/css application/xml;
		gzip_vary on;
		gzip_proxied        expired no-cache no-store private auth;
		gzip_disable        "MSIE [1-6]\.";

		#limit_zone  crawler  $binary_remote_addr  10m;

		server_tokens off;
		#log format
		log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '
             '$status $body_bytes_sent "$http_referer" '
             '"$http_user_agent" $http_x_forwarded_for';

server
	{
		listen       80;
		server_name www.lnmp.org;
		index index.html index.htm index.php;
		root  /home/wwwroot/default;

		location ~ .*\.(php|php5)?$
			{
				try_files $uri =404;
				fastcgi_pass  unix:/tmp/php-cgi.sock;
				fastcgi_index index.php;
				include fcgi.conf;
			}

		location /status {
			stub_status on;
			access_log   off;
		}

		location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
			{
				expires      30d;
			}

		location ~ .*\.(js|css)?$
			{
				expires      12h;
			}

		access_log  /home/wwwlogs/access.log  access;
	}
include vhost/*.conf;
}

OK, 다 됐 습 니 다. 마지막 으로 lngx 를 다시 시작 하면 됩 니 다.원 키 백 입 니 다. 직접 / root / lnmp restart 로 해결 하 겠 습 니 다.
미리 보기
http://test80.com/
http://test80.com:1010/
방문 성공!끝!
관련 문장 을 첨부 하 다
방화벽 오픈 포트
http://www.blogjava.net/Alpha/archive/2012/09/13/387640.html
http://www.myhack58.com/Article/48/66/2012/34999.htm
nginx 다 중 사이트 설정
http://highsea90.com/index.php/archives/899

좋은 웹페이지 즐겨찾기