麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 網站 > Nginx > 正文

Nginx 多站點配置實例詳解

2024-08-30 12:28:45
字體:
來源:轉載
供稿:網友

Nginx 多站點配置實例詳解

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

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

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

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

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:

service nginx restart

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

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


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 亚洲精品在线观看免费 | 杏美月av| 久久久一区二区三区精品 | 欧美精品一区二区久久 | 精品一区二区三区中文字幕老牛 | 国产欧美在线观看不卡一 | 黄色一级片在线免费观看 | 精品一区二区三区免费 | 欧美一级网 | 91精品国产一区二区三区四区在线 | 91丝袜| 一级做a爱片性色毛片高清 国产精品色在线网站 | 激情亚洲一区二区 | 蜜桃久久一区二区三区 | 亚洲第五色综合网 | 欧美一级毛片欧美一级成人毛片 | 国产精品一区二av18款 | 91精品动漫在线观看 | 黄色毛片免费视频 | 国产一国产精品一级毛片 | 国产中文av在线 | 亚州精品国产 | 成人短视频在线播放 | av在线播放免费 | 天天草天天干天天射 | 麻豆小视频在线观看 | 亚洲精品久久久久久 | 男女一边摸一边做羞羞视频免费 | 免费看黄色三级毛片 | 国产一区二区在线免费 | 国产精品久久久免费看 | 大学生一级毛片在线视频 | 亚洲一区二区中文字幕在线观看 | 国产一区视频观看 | 88xx成人精品视频 | 日韩精品二区 | 日本成人在线免费 | 欧美jizzhd极品欧美 | 草莓福利视频在线观看 | 毛片在线免费观看完整版 | 欧美性受xxxxxx黑人xyx性爽 |