首页 > 系统相关 >https部署与docker下nginx的转发+文件获取

https部署与docker下nginx的转发+文件获取

时间:2023-05-23 14:01:14浏览次数:47  
标签:set http Forwarded header nginx proxy https docker location

  1. 进入nginx容器查看是否有etc/nginx/cert目录
  2. 将https的域名证书放到cert目录下
  3. 配置80和443
server {
    #listen 80; #侦听80端口
    listen 80; #侦听443端口,用于SSL
    server_name  127.zyfdtsite.com;

    client_max_body_size 1024m;

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

    location / {
        proxy_set_header HOST $host;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://127.213.16.9:9000/;
        #add_header Content-Security-Policy upgrade-insecure-requests;
    }
    
    #前端大屏
    location /screen {
        alias /usr/share/nginx/screen;
        index index.html index.htm;
        #autoindex on;
    }
    location /api/ {
        proxy_set_header HOST $host;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://127.213.16.9:9001/;

    }
    
    location /ws {
            proxy_pass http://127.16.1.187:9004/;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
    }

    #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;
    }
}
server {
    #listen 80; #侦听80端口
    listen 443 ssl; #侦听443端口,用于SSL
    server_name  127.zyfdtsite.com;

    ssl_certificate /etc/nginx/cert/127.zyfdtsite.com_bundle.crt;
    ssl_certificate_key /etc/nginx/cert/127.zyfdtsite.com.key;
    ssl_session_timeout 5m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
    ssl_prefer_server_ciphers on;

    client_max_body_size 1024m;

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

    location / {
        proxy_set_header HOST $host;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://127.213.16.9:9000/;
        #add_header Content-Security-Policy upgrade-insecure-requests;
    }

    location /api/ {
        proxy_set_header HOST $host;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://127.213.16.9:9001/;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "Upgrade";
    }

    location /danyang/ {
        proxy_set_header HOST $host;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://127.213.16.9:9002/dyzyy/new/;
        #add_header Content-Security-Policy upgrade-insecure-requests;
    }

    location /danyang/dp/ {
        proxy_set_header HOST $host;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://127.213.16.9:9002/dyzyy/;
        #add_header Content-Security-Policy upgrade-insecure-requests;
    }

    location /danyang/api/ {
        proxy_set_header HOST $host;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://127.213.16.9:9002/zhongyiyuan/;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "Upgrade";
    }

    location /danyang/iot/ {
        proxy_set_header HOST $host;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://127.213.16.9:9002/iotZongyiyuan;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "Upgrade";
    }
    
    #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;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    #    root           html;
    #    fastcgi_pass   127.0.0.1:9000;
    #    fastcgi_index  index.php;
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    #    include        fastcgi_params;
    #}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}
  1. 新建容器时配置自启参数
    docker run --restart=always 容器id 或 容器名称
  2. 已存在的容器配置自启
    docker update --restart=always 容器id 或 容器名称
    另外:1)取消容器自启
    docker update --restart=no 容器id 或 容器名称
    2)批量设置容器自启
    docker update --restart=always $(docker ps -aq)

作者:袁天奇

标签:set,http,Forwarded,header,nginx,proxy,https,docker,location
From: https://www.cnblogs.com/DTCLOUD/p/17424729.html

相关文章

  • nginx常用配置
    常用配置路径代理映射http和https配置nginx路径下的配置文件:/etc/nginx/conf.d/nginx.conf (每个人的可能不一样,但是我这个就是yum直接安装的)如下配置配置http和https、ws和wss#自定义配置地址upstreamhalo{server127.0.0.1:8090;}server{listen80;l......
  • Nginx 可视化神器!复杂配置一键生成,监控管理一条龙!
    功能说明nginxWebUI是一款图形化管理nginx配置的工具,可以使用网页来快速配置nginx的各项功能,包括http协议转发、tcp协议转发、反向代理、负载均衡、静态html服务器、ssl证书自动申请、续签、配置等。配置好后可一建生成nginx.conf文件,同时可控制nginx使用此文件进行启动与重载,完成......
  • Docker如何上传本地文件到容器目录?
    先贴上命令:dockercp本地文件路径ID全称:容器路径下面来举个例子:我要把本地电脑的mysql-connector-java-5.1.46.jar上传到Linux下Docker里面的logstash容器下的/usr/share/logstash/lib目录。1.首先使用ssh工具上传jar包到Linux的/usr/local目录:2.使用docker命令赋值到docker容器......
  • 使用prometheus监控docker
    CAdvisorCAdvisor是Google开源的一款用于展示和分析容器运行状态的可视化工具。通过在主机上运行CAdvisor用户可以轻松的获取到当前主机上容器的运行统计信息,并以图表的形式向用户展示。安装部署#安装部署dockerpullgoogle/cadvisor:v0.24.1#centos7上安装指定版本#启动d......
  • nginx安装配置博客总结列表
    1)进入编辑配置文件:sudovim/etc/nginx/nginx.conf2)配置文件添加内容:3)重启nginxsudoservicenginxrestart//或者sudonginx-sreloadnginx相同域名转发不同路径:nginx域名监听转发:nginx转发同一域名的不同项目-多tomcat:......
  • 基于Docker安装RabbitMQ
    安装步骤1.在线拉取dockerpullrabbitmq:3-management2.安装RabbitMQdockerrun\-eRABBITMQ_DEFAULT_USER=wzh\-eRABBITMQ_DEFAULT_PASS=1234\-vmq-plugins:/plugins\--namemq\--hostnamemq\-p15672:15672\-p5672:5672\-d\rabbitmq:3-m......
  • docker 容器备份和恢复
    1、将容器生成镜像dockercommit-pe2882bb3b904keyan-42-backup-202305222、将镜像保存为tar文件dockersave-okeyan-42-backup-20230522.tarkeyan-42-backup-202305223、恢复dockerload-ikeyan-42-backup-20230522.tar ......
  • 四、Jenkins集成Docker
    重用之前的my_test项目增加Jenkins集成Docker。之前是构建完项目后,上传jar包并执行sh脚本启动jar包。现在是将jar包上传到Docker服务器上,并用Dockerfile构建镜像,启动容器。一、Jenkins新增SSHserver 找到SSHServers:  Jenkins部署在阿里云云主机上,这里用另一台云主机,......
  • docker的安装
    1.安装yum: 2.查看docker版本库版本由高到底: 3.指定docker版本进行安装: 4.启动docker服务命令: 5.设置docker在linux开机自动启动: 6.查看docker版本: 7.查看镜像: 8.拉取hello-world镜像: 9.拉取后查看hello-world的镜像: ......
  • docker-compose
    1、介绍docker-compose是一个用来定义和运行复杂应用的docker工具。其使用一个配置文件来管理多个Docker容器,在配置文件中,所有的容器通过services来定义,然后使用docker-compose脚本来启动,停止和重启应用,和应用中的服务以及所有依赖服务的容器,非常适合组合使用多个容器进行开发的......