专栏首页readmedjango nginx service
原创

django nginx service

# Django services
vim /usr/lib/systemd/system/X.service:
[Unit] 
Description=gitlabcontrolle
[Service] 
PrivateTmp=true
Restart=always 
Type=simple 
### Path and Port
ExecStart=/usr/bin/python /var/www/html/#X#Y#Z#/manage.py runserver 0.0.0.0:#8081#8082#8083
ExecStop=/usr/bin/kill -15 $MAINPID 
[Install] 
WantedBy=multi-user.target

# Nginx installation
### Preparation
cd /etc/yum.repos.d/
vim nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
### Installation:
yum install -y nginx
### Version:
nginx -v
### Grammer check
nginx -t

# Nginx Configuration
Assume address is helloworld.com
vim /etc/nginx/nginx.conf

user  nginx;
worker_processes  4;  ### check number of CPU core
error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;
events {
    worker_connections  1024; ### max connnection
}
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;
    keepalive_timeout  65;
    upstream X{
        server 127.0.0.1:8081;
    }
    upstream Y{
        server 127.0.0.1:8082;
    }
    upstream Z{
        server 127.0.0.1:8083;
    }
    ### Reverse Proxy to X.helloworld.com
    server {
        listen       443;
        ssl on;
        ssl_certificate /etc/pki/tls/CERTIFICATE.crt;
        ssl_certificate_key /etc/pki/PRIVATEKEY.key;
        server_name  X.helloworld.com;
        charset     utf-8;
        client_max_body_size 75M;
        location / {
            proxy_pass http://X;
            index  index.html index.htm;  
        }
    }
    ### Reverse Proxy to Y.helloworld.com
    server {
        listen       443;
        ssl on;
        ssl_certificate /etc/pki/tls/CERTIFICATE.crt;
        ssl_certificate_key /etc/pki/PRIVATEKEY.key;
        server_name  Y.helloworld.com;
        charset     utf-8;
        client_max_body_size 75M;
        location / {
            proxy_pass http://X;
            index  index.html index.htm;  
        }
    }
    ### Reverse Proxy to Z.helloworld.com
    server {
        listen       443;
        ssl on;
        ssl_certificate /etc/pki/tls/CERTIFICATE.crt;
        ssl_certificate_key /etc/pki/PRIVATEKEY.key;
        server_name  Z.helloworld.com;
        charset     utf-8;
        client_max_body_size 75M; 
        location / {
            proxy_pass http://Z;
            index  index.html index.htm;  
        }
    }   
    include /etc/nginx/conf.d/*.conf;
}

# Command when operation
systemctl status nginx
systemctl enable nginx
systemctl start nginx
systemctl stop nginx
systemctl restart nginx

原创声明,本文系作者授权云+社区发表,未经许可,不得转载。

如有侵权,请联系 yunjia_community@tencent.com 删除。

我来说两句

0 条评论
登录 后参与评论

相关文章

  • nginx + uwsgi + django configration

    readme
  • linux nginx uwsgi installation

    readme
  • Basic wechat mini program 基础微信小程序

    readme
  • (centos7)linux 搭建 nginx 负载均衡搭建

    版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

    suveng
  • [CentOS 7] 安装nginx

    下载对应当前系统版本的nginx包(package) # wget  http://nginx.org/packages/centos/7/noarch/RP...

    庞小明
  • 浅谈nginx

    nginx拥有极快处理静态资源的速度,这是tomcat无法对比的,可是nginx无法处理动态资源,处理动态资源还是需要我们的tomcat或者jetty处理等...

    聚沙成塔
  • CentOS安装nginx

    第二步,安装依赖包。(1)gcc安装。由于nginx是c语言写的,因此在安装nginx前需要先将官网下载的源码进行编译,编译依赖gcc环境,如果没有gcc环境,...

    编程思录
  • nginx代理其他端口到80端口-低调小熊猫的技术小黑屋

    我最近遇到微信授权认证回调的一个坑,本地测试的时候,我是用的内网穿透+端口,一切ok。等我配置公众号平台时,才发现微信那边只支持80端口,公司项目80端口已经被...

    用户2769131
  • CentOS7下使用nginx实现TCP和UDP代理

    nginx从1.9.0版本开始,新增了ngx_stream_core_module模块,使nginx支持四层负载均衡,实现TCP和UDP代理。默认编译的时候该模...

    yuanfan2012
  • linux开机自启动脚本

    Dean0731

扫码关注云+社区

领取腾讯云代金券