国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

服務器之家:專注于服務器技術及軟件下載分享
分類導航

云服務器|WEB服務器|FTP服務器|郵件服務器|虛擬主機|服務器安全|DNS服務器|服務器知識|Nginx|IIS|Tomcat|

服務器之家 - 服務器技術 - Nginx - Nginx 多站點配置實例詳解

Nginx 多站點配置實例詳解

2019-11-25 14:53lqh Nginx

這篇文章主要介紹了Nginx 多站點配置實例詳解的相關資料,需要的朋友可以參考下

Nginx 多站點配置實例詳解

在一臺 VPS 上,我們有時候需要同時跑幾個 virtualenv。比如 virtualenv app1 跑的是 Django 的一個應用,而 virtualenv app2 跑的是 Tornado。那么如何配置 Nginx,讓它同時支持這兩個 virtualenv 的運行呢?

首先是 Nginx 的主配置,位于 etc/nginx/ngnix.conf,讓它保持默認就行:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
user nginx;
worker_processes 1;
 
error_log /var/log/nginx/error.log warn;
pid    /var/run/nginx.pid;
 
 
events {
  worker_connections 1024;
}
 
 
http {
  include    /etc/nginx/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 /var/log/nginx/access.log main;
 
  sendfile    on;
  #tcp_nopush   on;
 
  keepalive_timeout 65;
 
  #gzip on;
 
  server {
    listen    80;
    server_name 112.124.7.216;
    #server_name localhost;
    #if ($host != 'www.nowamagic.net' ) {
    #  rewrite ^/(.*)$ http://www.nowamagic.net/$1 permanent;
    #}
 
    access_log /home/nowamagic/logs/access.log;
    error_log /home/nowamagic/logs/error.log;
 
    #root     /root/nowamagic_venv/nowamagic_pj;
    location / {
      uwsgi_pass 127.0.0.1:8077;
      #include uwsgi_params;
      include /etc/nginx/uwsgi_params;
      #uwsgi_pass 127.0.0.1:8077;
      #uwsgi_param UWSGI_SCRIPT index;
      #uwsgi_param UWSGI_PYHOME $document_root;
      #uwsgi_param UWSGI_CHDIR $document_root;
    }
 
    location ~ \.php$ {
      #root     html;
      root      /var/www/html;
      fastcgi_pass  127.0.0.1:9000;
      fastcgi_index index.php;
      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
      include    fastcgi_params;
    }
 
    access_log off;
  }
 
 
  include /etc/nginx/conf.d/*.conf;
}

注意到這一句,include /etc/nginx/conf.d/*.conf; 它會加載 conf.d 文件夾下的所有配置文件。那么接下來的事情就簡單了,我們設計兩個 .conf ,一個是 django 的配置,一個是 tornado 的配置。

1. app1_django.conf

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
server {
  listen    80;
  server_name 112.124.7.216;
  #server_name localhost;
  #if ($host != 'www.imofa.net' ) {
  #  rewrite ^/(.*)$ http://www.imofa.net/$1 permanent;
  #}
 
  access_log /home/nowamagic/logs/access.log;
  error_log /home/nowamagic/logs/error.log;
 
  #root     /root/nowamagic_venv/nowamagic_pj;
  location / {
    uwsgi_pass 127.0.0.1:8077;
    #include uwsgi_params;
    include /etc/nginx/uwsgi_params;
    #uwsgi_pass 127.0.0.1:8077;
    #uwsgi_param UWSGI_SCRIPT index;
    #uwsgi_param UWSGI_PYHOME $document_root;
    #uwsgi_param UWSGI_CHDIR $document_root;
  }
 
  location ~ \.php$ {
    #root     html;
    root      /var/www/html;
    fastcgi_pass  127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include    fastcgi_params;
  }
 
  access_log off;
}

下面是 tornado 的配置:

2. app2_tornado.conf

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
upstream tornado {
  server 127.0.0.1:8888;
}
 
server {
  listen  80;
  root /root/nmapp2_venv;
  index index.py index.html;
 
  server_name server;
 
  location / {
    #if (!-e $request_filename) {
    #  rewrite ^/(.*)$ /index.py/$1 last;
    #}
  }
 
  location ~ /index\.py {
    proxy_pass_header Server;
    proxy_set_header Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Scheme $scheme;
    proxy_pass http://tornado;
  }
}

重啟 Nginx:

?
1
service nginx restart

OK,兩個虛擬環境的 app 都能訪問了。

感謝閱讀,希望能幫助到大家,謝謝大家,對本站的支持!

原文鏈接:http://www.nowamagic.net/academy/detail/1226277

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 国产美女自拍视频 | 综合精品久久久 | 久热精品在线视频 | 亚洲精品一区二区三区蜜桃久 | 精品国产黄a∨片高清在线 成人欧美 | 日韩av一区二区在线观看 | 狠狠久久婷婷 | 欧美一级久久久 | 成人在线网址 | 欧美涩涩网站 | 国产一级一级国产 | 午夜亚洲 | 色视频www在线播放国产人成 | 一级黄色大片 | 91麻豆精品国产91久久久资源速度 | 精品福利视频网站 | 91av导航 | 看av网站 | 天天拍拍天天干 | 亚州中文字幕蜜桃视频 | 国产精品网站在线观看 | 亚洲精品乱码久久久久久蜜桃麻豆 | 国产一区二区三区在线免费观看 | 午夜欧美精品久久久久 | 日韩午夜在线 | 精精国产xxxx视频在线 | 亚洲福利影院 | 在线观看亚洲 | 91精品久久久久久 | 久久一区| 一区二区三区日韩 | 欧美日韩成人 | 日本不卡一区二区三区在线观看 | 成人免费视频视频在线观看 免费 | 伊人福利视频 | 日韩成人av电影在线观看 | 亚洲精品一区二区三区蜜桃久 | 欧美成人精品一区二区男人看 | 国产精品毛片在线 | 狠狠干av | 国产特级毛片aaaaaa高清 |