Flask - nginx部署

配置文件

  • alias : 别名, 定义location的其他名字, 在文件系统中能够找到
  • nginx和uwsgi配置
    • uwsgi_pass : 指定首页
user  root;
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  localhost;

    #charset koi8-r;
    #access_log  /var/log/nginx/host.access.log  main;
    root /root/myproject/flaskblog;

    location /static {
    		alias /root/myproject/flaskblog/static;
    }

    location / {
        include   /etc/nginx/uwsgi_params;
        uwsgi_pass  localhost:8080;
    }

    #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   /usr/share/nginx/html;
    }
}    
}

测试配置

  • nginx -t /root/myproject/flaskblog/nginx.conf

启动nginx

  • nginx -c /root/myproject/flaskblog/nginx.conf

启动uwsgi

  • uwsgi --ini /root/myproject/flaskblog/uwsgi.ini
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
Ingress-Nginx是一种Kubernetes中的Ingress控制器,用于管理入站流量,并将流量路由到Kubernetes集群中的服务。以下是部署Ingress-Nginx的步骤: 1. 安装Ingress-Nginx控制器。 使用以下命令安装控制器: ``` kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-0.32.0/deploy/static/provider/cloud/deploy.yaml ``` 该命令将部署由Ingress-Nginx维护的最新版本的控制器。 2. 验证控制器安装。 使用以下命令验证控制器是否已成功安装: ``` kubectl get pods -n ingress-nginx ``` 如果控制器已成功安装,则应看到类似于以下内容的输出: ``` NAME READY STATUS RESTARTS AGE ingress-nginx-admission-create-8gmgc 0/1 Completed 0 2m ingress-nginx-admission-patch-q8v2m 0/1 Completed 0 2m ingress-nginx-controller-5b4bcf79d8-9qz7j 1/1 Running 0 2m ``` 3. 部署应用程序。 使用以下命令部署您的应用程序: ``` kubectl apply -f your-application.yaml ``` 该命令将使用您的应用程序配置文件中指定的服务和端口部署应用程序。 4. 部署Ingress资源。 使用以下命令部署Ingress资源: ``` kubectl apply -f your-ingress.yaml ``` 该命令将使用您的Ingress配置文件中指定的规则和路径将流量路由到您的应用程序。 5. 验证Ingress是否生效。 使用以下命令验证Ingress是否已成功生效: ``` kubectl get ingress ``` 如果Ingress已成功生效,则应看到类似于以下内容的输出: ``` NAME HOSTS ADDRESS PORTS AGE your-ingress * 192.168.50.10 80 2m ``` 这意味着您的应用程序现在可以通过Ingress访问。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值