Nginx 실전 도 메 인 이름 을 지정 한 서버 포트 로 변경

1869 단어
1. 필드:
test. open. com 을 통 해 81 서버 가 지정 한 8081 포트 에 접근 합 니 다.
 
2. 적용:
2.1 먼저 클 라 우 드 서버 (여기 아 리 클 라 우 드 사용) 에서 open. com 의 1 급 도 메 인 이름 을 설정 합 니 다.
2.2 81 이 서버 에 nginx 를 설치 하고 nginx. conf 에서 설정 합 니 다. 설정 인 스 턴 스 는 다음 과 같 습 니 다.
   
    access_log  /web/logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    upstream tomcat_server {
        server    xxx.xx.xxx.81:8081 weight=1;
    }

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;

        server_name test.open.cn;

        charset utf-8;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;

            proxy_pass    http://tomcat_server;

            proxy_set_header   Host             $host;

            proxy_set_header   X-Real-IP        $remote_addr;

            proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
        }

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }



    http 요청 을 보 낼 때http://test.open.com먼저 1 급 도 메 인 이름 open. om 에 따라 xxx. xx. xxx. 81 서버 를 찾 은 다음 에 이 서버 에 nginx 를 설치 하고 80 포트 를 감청 (위 하 이 라이트) 했 습 니 다. 도 메 인 이름 이 test. open. cn 이라는 요청 이 오 면
   변경 요청 을 location 로 지정 하고 location 의 속성 proxypass, tomcatserver (위의 upstream 은 xxx. xx. xxx. 81 로 지정) 마지막 으로 http: xxx. xx. xxx. 81 로 바 뀌 었 습 니 다.

좋은 웹페이지 즐겨찾기