Kubernetes1.13.1 ingress nginx

1.如何获取集群中的服务

Kubernetes 暴露服务的方式目前只有三种:LoadBlancer Service、NodePort Service、Ingress;前两种估计都应该很熟悉,下面详细的了解下这个 Ingress

       Ingress由两部分组成:Ingress Controller 和 Ingress 服务。

       Ingress Contronler 通过与 Kubernetes API 交互,动态的去感知集群中 Ingress 规则变化,然后读取它,按照自定义的规则,规则就是写明了哪个域名对应哪个service,生成一段 Nginx 配置,再写到 Nginx-ingress-control的 Pod 里,这个 Ingress Contronler 的pod里面运行着一个nginx服务,控制器会把生成的nginx配置写入/etc/nginx.conf文件中,然后 reload 一下 使用配置生效。以此来达到域名分配置及动态更新的问题。

 

2.使用ingress的好处

Ingress可以简单的理解成k8s内部的nginx, 用作负载均衡器, 这样是有很多好处的.

  • 动态配置服务

如果按照传统方式, 当新增加一个服务时, 我们可能需要在流量入口加一个反向代理指向我们新的k8s服务. 而如果用了Ingress, 只需要配置好这个服务, 当服务启动时, 会自动注册到Ingress的中, 不需要而外的操作.

  • 减少不必要的端口暴露

配置过k8s的都清楚, 第一步是要关闭防火墙的, 主要原因是k8s的很多服务会以NodePort方式映射出去, 这样就相当于给宿主机打了很多孔, 既不安全也不优雅. 而Ingress可以避免这个问题, 除了Ingress自身服务可能需要映射出去, 其他服务都不要用NodePort方式.

3.配置文件ingress-nginx.yaml

 

---
apiVersion: v1
kind: Namespace
metadata:
  name: ingress-nginx
 
---
kind: ConfigMap
apiVersion: v1
metadata:
  name: tcp-services
  namespace: ingress-nginx
  labels:
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/part-of: ingress-nginx
 
---
kind: ConfigMap
apiVersion: v1
metadata:
  name: udp-services
  namespace: ingress-nginx
  labels:
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/part-of: ingress-nginx
 
---
kind: ConfigMap
apiVersion: v1
metadata:
  name: nginx-configuration
  namespace: ingress-nginx
  labels:
    app.kubernetes.io/name: ingress-nginx
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: default-http-backend
  labels:
    app.kubernetes.io/name: default-http-backend
    app.kubernetes.io/part-of: ingress-nginx
  namespace: ingress-nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: default-http-backend
  template:
    metadata:
      labels:
        app.kubernetes.io/name: default-http-backend
    spec:
      terminationGracePeriodSeconds: 60
      containers:
      - name: default-http-backend
        # Any image is permissible as long as:
        1. It serves a 404 page at /
        2. It serves 200 on a /healthz endpoint
        image: mirrorgooglecontainers/defaultbackend:1.4
        livenessProbe:
          httpGet:
            path: /healthz
            port: 8080
            scheme: HTTP
          initialDelaySeconds: 30
          timeoutSeconds: 5
        ports:
        - containerPort: 8080
        resources:
          limits:
            cpu: 10m
            memory: 20Mi
          requests:
            cpu: 10m
            memory: 20Mi
---
apiVersion: v1
kind: Service
metadata:
  name: default-http-backend
  namespace: ingress-nginx
  labels:
    app.kubernetes.io/name: default-http-backend
    app.kubernetes.io/part-of: ingress-nginx
spec:
  ports:
  - port: 80
    targetPort: 8080
  selector:
    app.kubernetes.io/name: default-http-backend
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: nginx-ingress-serviceaccount
  namespace: ingress-nginx
 
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
  name: nginx-ingress-clusterrole
rules:
  - apiGroups:
      ""
    resources:
      - configmaps
      - endpoints
      - nodes
      - pods
      - secrets
    verbs:
      - list
      - watch
  - apiGroups:
      ""
    resources:
      - nodes
    verbs:
      - get
  - apiGroups:
      ""
    resources:
      - services
    verbs:
      - get
      - list
      - watch
  - apiGroups:
      "extensions"
    resources:
      - ingresses
    verbs:
      - get
      - list
      - watch
  - apiGroups:
      ""
    resources:
        - events
    verbs:
        - create
        - patch
  - apiGroups:
      "extensions"
    resources:
      - ingresses/status
    verbs:
      - update
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: Role
metadata:
  name: nginx-ingress-role
  namespace: ingress-nginx
rules:
  - apiGroups:
      ""
    resources:
      - configmaps
      - pods
      - secrets
      - namespaces
    verbs:
      - get
  - apiGroups:
      ""
    resources:
      - configmaps
    resourceNames:
      # Defaults to "<election-id>-<ingress-class>"
      # Here: "<ingress-controller-leader>-<nginx>"
      # This has to be adapted if you change either parameter
      # when launching the nginx-ingress-controller.
      "ingress-controller-leader-nginx"
    verbs:
      - get
      - update
  - apiGroups:
      ""
    resources:
      - configmaps
    verbs:
      - create
  - apiGroups:
      ""
    resources:
      - endpoints
    verbs:
      - get
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: RoleBinding
metadata:
  name: nginx-ingress-role-nisa-binding
  namespace: ingress-nginx
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: nginx-ingress-role
subjects:
  - kind: ServiceAccount
    name: nginx-ingress-serviceaccount
    namespace: ingress-nginx
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
  name: nginx-ingress-clusterrole-nisa-binding
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: nginx-ingress-clusterrole
subjects:
  - kind: ServiceAccount
    name: nginx-ingress-serviceaccount
    namespace: ingress-nginx
 
---
apiVersion: v1
kind: Service
metadata:
  name: ingress-nginx
  namespace: ingress-nginx
  labels:
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/part-of: ingress-nginx
spec:
  type: NodePort
  ports:
    - name: http
      port: 80
      targetPort: 80
      protocol: TCP
    - name: https
      port: 443
      targetPort: 443
      protocol: TCP
  selector:
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/part-of: ingress-nginx
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: nginx-ingress-controller
  namespace: ingress-nginx
  labels:
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/part-of: ingress-nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: ingress-nginx
      app.kubernetes.io/part-of: ingress-nginx
  template:
    metadata:
      labels:
        app.kubernetes.io/name: ingress-nginx
        app.kubernetes.io/part-of: ingress-nginx
      annotations:
        prometheus.io/port: '10254'
        prometheus.io/scrape: 'true'
    spec:
      serviceAccountName: nginx-ingress-serviceaccount
      hostNetwork: true
      nodeSelector:
        ingress: kube-node2-proxy
      containers:
        - name: nginx-ingress-controller
          image: quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.19.0
          args:
            - /nginx-ingress-controller
            - --default-backend-service=$(POD_NAMESPACE)/default-http-backend
            - --configmap=$(POD_NAMESPACE)/nginx-configuration
            - --tcp-services-configmap=$(POD_NAMESPACE)/tcp-services
            - --udp-services-configmap=$(POD_NAMESPACE)/udp-services
            - --publish-service=$(POD_NAMESPACE)/ingress-nginx
            - --annotations-prefix=nginx.ingress.kubernetes.io
          securityContext:
            capabilities:
                drop:
                - ALL
                add:
                - NET_BIND_SERVICE
            # www-data -> 33
            runAsUser: 33
          env:
            - name: POD_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
            - name: POD_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
          ports:
          - name: http
            containerPort: 80
          - name: https
            containerPort: 443
          - name: other
            containerPort: 8888
          livenessProbe:
            failureThreshold: 3
            httpGet:
              path: /healthz
              port: 10254
              scheme: HTTP
            initialDelaySeconds: 10
            periodSeconds: 10
            successThreshold: 1
            timeoutSeconds: 1
          readinessProbe:
            failureThreshold: 3
            httpGet:
              path: /healthz
              port: 10254
              scheme: HTTP
            periodSeconds: 10
            successThreshold: 1
            timeoutSeconds: 1

 

4.启动服务

[root@iZbp13ke7onfhiq7ycl4m0Z ingress-nginx]# kubectl get no
NAME            STATUS   ROLES    AGE   VERSION
10.46.228.139   Ready    <none>   29d   v1.13.1
10.80.239.121   Ready    <none>   29d   v1.13.1
[root@iZbp13ke7onfhiq7ycl4m0Z ingress-nginx]# kubectl label nodes 10.80.239.121  ingress=kube-node2-proxy --overwrite
node/10.80.239.121 labeled
[root@iZbp13ke7onfhiq7ycl4m0Z ingress-nginx]# kubectl create -f ingress-nginx.yaml
namespace/ingress-nginx created
configmap/tcp-services created
configmap/udp-services created
configmap/nginx-configuration created
deployment.extensions/default-http-backend created
service/default-http-backend created
serviceaccount/nginx-ingress-serviceaccount created
clusterrole.rbac.authorization.k8s.io/nginx-ingress-clusterrole created
role.rbac.authorization.k8s.io/nginx-ingress-role created
rolebinding.rbac.authorization.k8s.io/nginx-ingress-role-nisa-binding created
clusterrolebinding.rbac.authorization.k8s.io/nginx-ingress-clusterrole-nisa-binding created
service/ingress-nginx created
deployment.extensions/nginx-ingress-controller created
[root@iZbp13ke7onfhiq7ycl4m0Z ingress-nginx]# kubectl get po -o wide -n ingress-nginx
NAME                                        READY   STATUS              RESTARTS   AGE   IP              NODE            NOMINATED NODE   READINESS GATES
default-http-backend-78c9688697-q7x8h       1/1     Running             0          43s   172.33.42.13    10.46.228.139   <none>           <none>
nginx-ingress-controller-54cbc84cd9-jfsnj   0/1     Running   0          43s   10.80.239.121   10.80.239.121   <none>           <none>

 

 

5.测试负载均衡功能

5.1 获取service名称

[root@iZbp1at8fph52evh70atb1Z ingress]# kubectl get svc
NAME                       TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                          AGE
ask-bar-async-service      NodePort    10.254.16.33     <none>        8080:31160/TCP                   113m
ask-bar-service            NodePort    10.254.44.241    <none>        8080:31158/TCP                   113m
ask-bar-web-server         NodePort    10.254.27.37     <none>        8080:31159/TCP                   113m
cloud-async-service        NodePort    10.254.61.108    <none>        8080:31155/TCP                   111m
cloud-service              NodePort    10.254.110.18    <none>        8080:31153/TCP                   111m
cloud-web-server           NodePort    10.254.92.19     <none>        8080:31154/TCP                   111m
cs-async-service           NodePort    10.254.183.117   <none>        8080:31150/TCP                   112m
cs-service                 NodePort    10.254.104.234   <none>        8080:31151/TCP                   113m
cs-web-server              NodePort    10.254.144.86    <none>        8080:31152/TCP                   113m
exam-async-service         NodePort    10.254.71.41     <none>        8080:31147/TCP                   112m
exam-service               NodePort    10.254.202.108   <none>        8080:31148/TCP                   112m
exam-web-server            NodePort    10.254.132.89    <none>        8080:31149/TCP                   112m
file-doc-listen            NodePort    10.254.212.70    <none>        8080:31190/TCP                   111m
file-doc-listen-cloud      NodePort    10.254.201.30    <none>        8080:31191/TCP                   111m
graphite                   NodePort    10.254.103.12    <none>        80:30003/TCP,2003:30004/TCP      6h35m
human-resource-async       NodePort    10.254.142.159   <none>        8080:31144/TCP                   113m
human-resource-service     NodePort    10.254.236.168   <none>        8080:31145/TCP                   113m
human-resource-web         NodePort    10.254.236.171   <none>        8080:31146/TCP                   113m
kubernetes                 ClusterIP   10.254.0.1       <none>        443/TCP                          10d
message-send               NodePort    10.254.255.151   <none>        8080:31162/TCP                   113m
microclass-async-service   NodePort    10.254.133.95    <none>        8080:31180/TCP                   111m
microclass-service         NodePort    10.254.137.145   <none>        8080:31175/TCP                   111m
microclass-web-server      NodePort    10.254.66.39     <none>        8080:31176/TCP                   111m
mongodb                    NodePort    10.254.158.84    <none>        27017:30005/TCP                  7d21h
oauth-provider             NodePort    10.254.168.75    <none>        8080:31143/TCP                   113m
quick-report-boot          NodePort    10.254.228.30    <none>        8080:31168/TCP                   111m
quick-report-redis         NodePort    10.254.63.94     <none>        6379:30016/TCP                   10d
rabbitmq                   NodePort    10.254.182.246   <none>        5672:30007/TCP,15672:34001/TCP   7d21h
redis                      NodePort    10.254.123.5     <none>        6379:30006/TCP                   7d21h
security-center            NodePort    10.254.202.173   <none>        9001:31174/TCP                   112m
system-async-service       NodePort    10.254.251.199   <none>        8080:31110/TCP                   113m
system-service             NodePort    10.254.170.241   <none>        8080:31141/TCP                   114m
system-web-server          NodePort    10.254.176.22    <none>        8080:31142/TCP                   114m
training-async-service     NodePort    10.254.41.169    <none>        8080:31161/TCP                   112m
training-service           NodePort    10.254.219.76    <none>        8080:31156/TCP                   112m
training-web-server        NodePort    10.254.10.228    <none>        8080:31157/TCP                   112m
zookeeper                  NodePort    10.254.91.96     <none>        2181:30002/TCP                   8d
zxy-log-async-service      NodePort    10.254.14.105    <none>        8080:31169/TCP                   112m
zxy-log-service            NodePort    10.254.107.224   <none>        8080:31171/TCP                   112m
zxy-log-web-server         NodePort    10.254.141.189   <none>        8080:31170/TCP                   112m


5.2 编辑ingress配置文件/app/zxy9.yaml,注意host代表nginx的虚拟主机,名字不能重复,system-web-server,cs-web-server代表虚拟主机的域名

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: zxy9-ingress
  namespace: default
spec:
  rules:
  - host: system-web-server
    http:
      paths:
      - path: /
        backend:
          serviceName: system-web-server
          servicePort: 8080
  - host: cs-web-server
    http:
      paths:
      - path: /
        backend:
          serviceName: cs-web-server
          servicePort: 8080

5.3在要访问system-web-server与cs-web-server服务的机器上修改/etc/hosts,添加如下内容

10.46.76.31 system-web-server
10.46.76.31 cs-web-server
10.46.76.31为nginx-ingress-controller运行的机器IP
[root@iZbp1at8fph52evh70atb1Z ingress]# cat /etc/hosts
127.0.0.1 localhost
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
10.47.92.186 iZbp1at8fph52evh70atb1Z zxytest.zhixueyun.com
10.46.76.31 iZbp1at8fph52evh70atb0Z
10.47.92.186    kube-node1 
10.46.76.31    kube-node2 
10.27.225.115 docker.zhixueyun.com
10.162.70.87 test9.zhixueyun.com
10.81.56.163  kube-node3 iZbp126awga24id4dhyokoZ
10.46.76.31 system-web-server
10.46.76.31 cs-web-server

 

5.4通过ingress配置的域名访问相应的服务

http://cs-web-server/api/v1/course-study/course-front/member-company?_=1546587538777

http://system-web-server/api/v1/system/setting?_=1546586653632

5.5 经测试发现ingress-nginx的通过hosts配置负载均衡方式不适合zxy9产品,原因是nginx-ingress-controller针对每个服务必须设置一个虚拟主机即访问域名,并且每个虚拟主机名称必须不相同,比如exam.zhixueyun.com,course.zhixueyun.com,不能全部是同一个虚拟主机,比如course,exam服务都使用zxytest.zhixueyun.com,像如下配置,就会导致nginx-ingress-controller不能正常工作

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: zxy9-ingress
  namespace: default
spec:
  rules:
  - host: zxytest.zhixueyun.com
    http:
      paths:
      - path: /
        backend:
          serviceName: system-web-server
          servicePort: 8080
  - host: zxytest.zhixueyun.com
    http:
      paths:
      - path: /
        backend:
          serviceName: cs-web-server
          servicePort: 8080

 

而zxy9产品的所有服务必须使用同一个域名访问,比如http://zxytest.zhixueyun.com/api/v1/course-study/course-front/member-company?_=1546587538777,https://zxytest.zhixueyun.com/oauth/api/v1/token/error-count?username=admin&organization_id=1根路径必须使用zxytest.zhixueyun.com访问,当使用http://course.zhixueyun.com/api/v1/course-study/course-front/member-company?_=1546587538777https://oauth.zhixueyun.com/oauth/api/v1/token/error-count?username=admin&organization_id=1访问的时候会返回401错误,代码上面做了安全限制,所以ingress-nginx的hosts配置负载均衡方式不适合zxy9产品

 

6.可以使用不同path的方式配置ingress nginx,

nginx.ingress.kubernetes.io/proxy-body-size: "2048m"一定要加上,否则上传文件将出现413错误
6.1 zxy9.yaml配置文件内容如下:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: zxy9-ingress
  namespace: default
  annotations:
    nginx.ingress.kubernetes.io/proxy-body-size: "2048m"
spec:
  rules:
  - host: zxytest.zhixueyun.com
    http:
      paths:
      - path: /api/v1/system/
        backend:
          serviceName: system-web-server
          servicePort: 8080
      - path: /api/v1/course-study/
        backend:
          serviceName: cs-web-server
          servicePort: 8080
      - path: /api/v1/human/
        backend:
          serviceName: human-resource-web
          servicePort: 8080
      - path: /api/v1/exam/
        backend:
          serviceName: exam-web-server
          servicePort: 8080
      - path: /api/v1/training/
        backend:
          serviceName: training-web-server
          servicePort: 8080
      - path: /api/v1/microclass/
        backend:
          serviceName: microclass-web-server
          servicePort: 8080
      - path: /api/v1/ask-bar/
        backend:
          serviceName: ask-bar-web-server
          servicePort: 8080
      - path: /oauth/
        backend:
          serviceName: oauth-provider
          servicePort: 8080
      - path: /api/v1/zxy-log/
        backend:
          serviceName: zxy-log-web-server
          servicePort: 8080
      - path: /security-center/
        backend:
          serviceName: security-center
          servicePort: 8080
      - path: /static/
        backend:
          serviceName: quick-report-boot
          servicePort: 8080
      - path: /quick-report-web/compute/
        backend:
          serviceName: quick-report-boot
          servicePort: 8080
      - path: /quick-report-web/api/
        backend:
          serviceName: quick-report-boot
          servicePort: 8080
      - path: /quick-report-web/reportInfo/
        backend:
          serviceName: quick-report-boot
          servicePort: 8080      
      - path: /quick-report/
        backend:
          serviceName: quick-report-boot
          servicePort: 8080      
      - path: /api/v1/live/
        backend:
          serviceName: live-web-server
          servicePort: 8080
      - path: /api/v1/cloud-center/
        backend:
          serviceName: cloud-web-server
          servicePort: 8080
      - path: /api/v1/hr-sync/
        backend:
          serviceName: hr-sync-web-server
          servicePort: 8080
      - path: /api/v1/history/
        backend:
          serviceName: history-web-server
          servicePort: 8080
      - path: /api/v1/message/
        backend:
          serviceName: message-send
          servicePort: 8080
      - path: /api/v1/help-center/
        backend:
          serviceName: help-center-web-server
          servicePort: 8080                        


6.2 最终的nginx配置文件如下

user  root;
worker_processes  16;
error_log  logs/error-old.log warn;
pid        logs/nginx-old.pid;
 
events {
    worker_connections  65535;
}
 
http {
    include       /app/nginx/conf/mime.types;
    default_type  application/octet-stream;
     server_names_hash_bucket_size 128;
     client_header_buffer_size 32k;
     large_client_header_buffers 4 32k;
     client_body_timeout 600s;
     client_max_body_size 5000m;
     access_log on;
     sendfile on;
     tcp_nopush     on;
     keepalive_timeout 600s;
     tcp_nodelay on;
     server_tokens off;
     fastcgi_connect_timeout 600s;
     fastcgi_send_timeout 600s;
     fastcgi_read_timeout 600s;
     fastcgi_buffer_size 128k;
     fastcgi_buffers 8 128k;
     fastcgi_busy_buffers_size 256k;
     fastcgi_temp_file_write_size 256k;
     ##cache##
     proxy_connect_timeout 600s;
     proxy_read_timeout 600s;
     proxy_send_timeout 600s;
     proxy_buffer_size 32k;
     proxy_buffers 8 128k;
     proxy_busy_buffers_size 256k;
     proxy_temp_file_write_size 256k;
     proxy_temp_path /app/nginx/temp;
     proxy_cache_path /app/nginx/cache levels=1:2 keys_zone=cache_one:200m inactive=1d max_size=30g;
     ##end##
     gzip    on;
     gzip_min_length   1k;
     gzip_buffers   4 8k;
     gzip_http_version  1.1;
     gzip_types  application/json  text/plain application/x-javascript text/css  application/xml;
     gzip_disable "MSIE [1-6]\.";
    upstream fastdfs_address{
    server  localhost:10402;
    }
    upstream zxy-scorm_address{
    server  localhost:8000;
    }
    upstream fileInfo_address{
    server  localhost:9000;
    }
 
    server {
        listen 80;
        server_name *.zhixueyun.com;
        default_type 'text/html';
        charset utf-8;
        return 301 https://$host$request_uri;
        }
 
    server {
        listen 449;
        server_name_in_redirect off;
        port_in_redirect off;
        access_log /dev/null;
        server_name *.zhixueyun.com;
        root /app/content/http/data/;
        add_header Access-Control-Allow-Origin *;
        add_header Access-Control-Allow-Headers X-Requested-With;
        add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
       location /zxy-libs{
         root /app/nginx/html/;
        }
    location /installer{
         root /app/nginx/html/;
        }
        location ~/fileInfo {
           proxy_redirect off;
           proxy_set_header Host $host;
           proxy_set_header X-Real-Ip $http_x_forwarded_for;
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
           proxy_pass http://fileInfo_address;
        }
        location /api/v1/security-center {
            proxy_pass http://zxytest.zhixueyun.com;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
        location /api/v1/hr-sync {
            proxy_pass http://zxytest.zhixueyun.com;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
        location /oauth {
            proxy_set_header X-Forwarded-Scheme $scheme;
            root /app/nginx/html;
            #index_oauth
            index index-49dd2a6796.html;
        }
        location ~^/default/M00/ {
              root /app/content/http/data/;
        }
 
      location /data {
          proxy_pass http://data.zhixueyun.com;
          proxy_set_header X-Real-Ip $http_x_forwarded_for;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      }
 
      location /dashboard {
          root /app/nginx/html;
      }
        location /browser {
              root /app/nginx/html/;
        }
        location /subject {
            root /app/nginx/html;
        }
 
        location /quick-report-web {
            root /app/nginx/html;
        }
        location /vue-admin/ {
            alias /app/nginx/html/quick-report-web/;
        }
        location / {
             #upgrade_page.html
#            root /app/nginx/html/;
#            index upgrade_page.html;
            root /app/nginx/html/student;
#            #index_student
            index index-1732c88772.html;
        }
        location /admin {
            root /app/nginx/html/;
            #index_admin
            index index-ecb8d95615.html;
        }
       location /live{
         root /app/nginx/html/;
        }
       location /app{
         root /app/nginx/html/;
        }
       location ~/hls{
         root /app/nginx/html/;
        }
       location ~/mp4{
         root /app/nginx/html/;
        }
       location ~/js-sdk{
         root /app/nginx/html/;
        }
       location ~/scorm-file {
         root /app/content/;
        }
 
        location /pc/share/ {
        #如果是app
        if ($http_user_agent ~ "^((.*MIDP.*)|(.*WAP.*)|(.*UP.Browser.*)|(.*Smartphone.*)|(.*Obigo.*)|(.*Mobile.*)|(.*AU.Browser.*)|(.*wxd.Mms.*)|(.*WxdB.Browser.*)|(.*CLDC.*)|(.*UP.Link.*)|(.*KM.Browser.*)|(.*UCWEB.*)|(.*SEMC\-Browser.*)|(.*Mini.*)|(.*Symbian.*)|(.*Palm.*)|(.*Nokia.*)|(.*Panasonic.*)|(.*MOT\-.*)|(.*SonyEricsson.*)|(.*NEC\-.*)|(.*Alcatel.*)|(.*Ericsson.*)|(.*BENQ.*)|(.*BenQ.*)|(.*Amoisonic.*)|(.*Amoi\-.*)|(.*Capitel.*)|(.*PHILIPS.*)|(.*SAMSUNG.*)|(.*Lenovo.*)|(.*Mitsu.*)|(.*Motorola.*)|(.*SHARP.*)|(.*WAPPER.*)|(.*LG\-.*)|(.*LG/.*)|(.*EG900.*)|(.*CECT.*)|(.*Compal.*)|(.*kejian.*)|(.*Bird.*)|(.*BIRD.*)|(.*G900/V1.0.*)|(.*Arima.*)|(.*CTL.*)|(.*TDG.*)|(.*Daxian.*)|(.*DAXIAN.*)|(.*DBTEL.*)|(.*Eastcom.*)|(.*EASTCOM.*)|(.*PANTECH.*)|(.*Dopod.*)|(.*Haier.*)|(.*HAIER.*)|(.*KONKA.*)|(.*KEJIAN.*)|(.*LENOVO.*)|(.*Soutec.*)|(.*SOUTEC.*)|(.*SAGEM.*)|(.*SEC\-.*)|(.*SED\-.*)|(.*EMOL\-.*)|(.*INNO55.*)|(.*ZTE.*)|(.*iPhone.*)|(.*Android.*)|(.*Windows CE.*)|(java.*)|(Opera.*))$" )
        {
        rewrite ^ https://$host/app/share;
        }
        #如果是pc
        rewrite ^ https://$host;
        }
 
        location ^~ /oauth/api/v1 {
            proxy_set_header X-Forwarded-Scheme $scheme;
            proxy_pass http://zxytest.zhixueyun.com/oauth;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_set_header X-Forwarded-URI $request_uri;
        }
        location ^~ /oauth/auth {
            proxy_set_header X-Forwarded-Scheme $scheme;
            proxy_pass http://zxytest.zhixueyun.com/oauth/auth;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_set_header X-Forwarded-URI $request_uri;
        }
        location /api/v1/microclass {
            proxy_pass http://zxytest.zhixueyun.com;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
        location /api/v1/ {
            proxy_set_header X-Forwarded-Scheme $scheme;
            proxy_pass http://zxytest.zhixueyun.com/;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }
        location /auth {
            proxy_set_header X-Forwarded-Scheme $scheme;
            proxy_pass http://zxytest.zhixueyun.com/auth;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }
 
        location /quick-report-web/api/ {
            proxy_pass http://zxytest.zhixueyun.com/;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }
        location /static/ {
            proxy_pass http://zxytest.zhixueyun.com/static/;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }
        location /quick-report-web/compute/ {
            proxy_pass http://zxytest.zhixueyun.com/compute/;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }
        location /quick-report-web/reportInfo/ {
            proxy_pass http://zxytest.zhixueyun.com/reportInfo/;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }
        location /quick-report {
            proxy_pass http://zxytest.zhixueyun.com;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }
 
        location /node/api/v1/ {
            proxy_pass http://10.47.92.186:31186/;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
       location /logs
       {
          root /app/nginx/html/;
          autoindex on;
          autoindex_exact_size on;
          autoindex_localtime on;
          auth_basic "secret";
          auth_basic_user_file /app/nginx/conf/.logs_passwd.db;
       }
       location ~/zxy-scorm {
           proxy_redirect off;
           proxy_set_header Host $host;
           proxy_set_header X-Real-Ip $http_x_forwarded_for;
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
           proxy_pass http://zxy-scorm_address;
        }
       location ^~ /scorm-unzip {
           proxy_redirect off;
           proxy_set_header Host $host;
           proxy_set_header X-Real-Ip $http_x_forwarded_for;
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
           proxy_pass http://zxy-scorm_address;
        }
      location ^~ /demo {
           proxy_redirect off;
           proxy_set_header Host $host;
           proxy_set_header X-Real-Ip $http_x_forwarded_for;
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
           proxy_pass http://zxy-scorm_address;
        }
      location ^~ /videojs {
           proxy_redirect off;
           proxy_set_header Host $host;
           proxy_set_header X-Real-Ip $http_x_forwarded_for;
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
           proxy_pass http://zxy-scorm_address;
        }
      location /admin/default/M00 {
           alias /app/content/http/data/default/M00;
        }
      location ~^/default/M00/.*(?<!\.mp4|/)$ {
              root /app/content/http/data/;
              ngx_fastdfs_module;
      }
      location ~^/default/M00/.*\.(mp4)$ {
             mp4;
      }
      error_page 500 404 /404.html;
        location = /404.html {
              root /app/nginx/html;
              internal;
        }
      error_page 400 =200 @400
      location @400 
        root /app/content/http/data;
     }
        location /cloud {
            root /app/nginx/html;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
 
        location /api/v1/human {
            proxy_pass http://zxytest.zhixueyun.com;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
        location /api/v1/help-center {
            proxy_pass http://zxytest.zhixueyun.com;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
        location /api/v1/history {
            proxy_set_header X-Forwarded-Scheme $scheme;
            proxy_pass http://zxytest.zhixueyun.com;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
        location /api/v1/system {
            proxy_pass http://zxytest.zhixueyun.com;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
        location /api/v1/message {
            proxy_pass http://zxytest.zhixueyun.com;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
        location /api/v1/zxy-log {
            proxy_pass http://zxytest.zhixueyun.com;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
        location /api/v1/report {
            proxy_pass http://10.47.92.186:31166;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }
 
        location /api/v1/exam/ws {
            proxy_pass http://zxytest.zhixueyun.com;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }
        location /api/v1/exam {
            proxy_pass http://zxytest.zhixueyun.com;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }
        location /api/v1/course-study {
            proxy_pass http://zxytest.zhixueyun.com;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
        location /api/v1/ask-bar {
            proxy_pass http://zxytest.zhixueyun.com;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
        location /api/v1/ask-bar/ws {
            proxy_pass http://zxytest.zhixueyun.com;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }
        location /api/v1/training {
            proxy_pass http://zxytest.zhixueyun.com;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
        location /api/v1/training/ws {
            proxy_pass http://zxytest.zhixueyun.com;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }
        location /api/v1/cloud-center {
            proxy_pass http://zxytest.zhixueyun.com;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
        location /api/v1/cloud-center/ws {
            proxy_pass http://zxytest.zhixueyun.com;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }
        location /api/v1/live {
            proxy_pass http://zxytest.zhixueyun.com;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
        location /ws/live/ {
            proxy_pass http://10.47.92.186:31192/;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
}
##############   443  ####################
    server {
        listen 443;
        server_name_in_redirect off;
        port_in_redirect off;
        access_log /dev/null;
        server_name *.zhixueyun.com;
        root /app/content/http/data/;
        add_header Access-Control-Allow-Origin *;
        add_header Access-Control-Allow-Headers X-Requested-With;
        add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
        ssl on;
        ssl_certificate /app/nginx/conf/server.crt;
        ssl_certificate_key /app/nginx/conf/server.key;
        ssl_session_timeout 5m;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
        ssl_prefer_server_ciphers off;
        location ~/fileInfo {
           proxy_redirect off;
           proxy_set_header Host $host;
           proxy_set_header X-Real-Ip $http_x_forwarded_for;
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
           proxy_pass http://fileInfo_address;
        }
        location /api/v1/security-center {
            proxy_pass http://zxytest.zhixueyun.com;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
        location /api/v1/hr-sync {
            proxy_pass http://zxytest.zhixueyun.com;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
        location /oauth {
            proxy_set_header X-Forwarded-Scheme $scheme;
            root /app/nginx/html;
            #index_oauth
            index index-49dd2a6796.html;
        }
        location ~^/default/M00/ {
              root /app/content/http/data/;
        }
 
      location /data {
          proxy_pass http://data.zhixueyun.com;
          proxy_set_header X-Real-Ip $http_x_forwarded_for;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      }
 
      location /dashboard {
          root /app/nginx/html;
      }
        location /browser {
              root /app/nginx/html/;
        }
        location /subject {
            root /app/nginx/html;
        }
        location /quick-report-web {
            root /app/nginx/html;
        }
        location /vue-admin/ {
            alias /app/nginx/html/quick-report-web/;
        }
        location / {
            root /app/nginx/html/student;
#            #index_student
            index index-1732c88772.html;
        }
        location /admin {
            root /app/nginx/html/;
            #index_admin
            index index-ecb8d95615.html;
        }
       location /zxy-libs{
         root /app/nginx/html/;
        }
       location /live{
         root /app/nginx/html/;
        }
       location /app{
         root /app/nginx/html/;
        }
       location ~/hls{
         root /app/nginx/html/;
        }
       location ~/scorm-file {
         root /app/content/;
        }
 
        location /pc/share/ {
        #如果是app
        if ($http_user_agent ~ "^((.*MIDP.*)|(.*WAP.*)|(.*UP.Browser.*)|(.*Smartphone.*)|(.*Obigo.*)|(.*Mobile.*)|(.*AU.Browser.*)|(.*wxd.Mms.*)|(.*WxdB.Browser.*)|(.*CLDC.*)|(.*UP.Link.*)|(.*KM.Browser.*)|(.*UCWEB.*)|(.*SEMC\-Browser.*)|(.*Mini.*)|(.*Symbian.*)|(.*Palm.*)|(.*Nokia.*)|(.*Panasonic.*)|(.*MOT\-.*)|(.*SonyEricsson.*)|(.*NEC\-.*)|(.*Alcatel.*)|(.*Ericsson.*)|(.*BENQ.*)|(.*BenQ.*)|(.*Amoisonic.*)|(.*Amoi\-.*)|(.*Capitel.*)|(.*PHILIPS.*)|(.*SAMSUNG.*)|(.*Lenovo.*)|(.*Mitsu.*)|(.*Motorola.*)|(.*SHARP.*)|(.*WAPPER.*)|(.*LG\-.*)|(.*LG/.*)|(.*EG900.*)|(.*CECT.*)|(.*Compal.*)|(.*kejian.*)|(.*Bird.*)|(.*BIRD.*)|(.*G900/V1.0.*)|(.*Arima.*)|(.*CTL.*)|(.*TDG.*)|(.*Daxian.*)|(.*DAXIAN.*)|(.*DBTEL.*)|(.*Eastcom.*)|(.*EASTCOM.*)|(.*PANTECH.*)|(.*Dopod.*)|(.*Haier.*)|(.*HAIER.*)|(.*KONKA.*)|(.*KEJIAN.*)|(.*LENOVO.*)|(.*Soutec.*)|(.*SOUTEC.*)|(.*SAGEM.*)|(.*SEC\-.*)|(.*SED\-.*)|(.*EMOL\-.*)|(.*INNO55.*)|(.*ZTE.*)|(.*iPhone.*)|(.*Android.*)|(.*Windows CE.*)|(java.*)|(Opera.*))$" )
        {
        rewrite ^ https://$host/app/share;
        }
        #如果是pc
        rewrite ^ https://$host;
        }
 
        location ^~ /oauth/api/v1 {
            proxy_set_header X-Forwarded-Scheme $scheme;
            proxy_pass http://zxytest.zhixueyun.com/oauth;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_set_header X-Forwarded-URI $request_uri;
        }
        location ^~ /oauth/auth {
            proxy_set_header X-Forwarded-Scheme $scheme;
            proxy_pass http://zxytest.zhixueyun.com/oauth/auth;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_set_header X-Forwarded-URI $request_uri;
        }
        location /api/v1/microclass {
            proxy_pass http://zxytest.zhixueyun.com;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
        location /api/v1/ {
            proxy_set_header X-Forwarded-Scheme $scheme;
            proxy_pass http://zxytest.zhixueyun.com/;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }
        location /auth {
            proxy_set_header X-Forwarded-Scheme $scheme;
            proxy_pass http://zxytest.zhixueyun.com/auth;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }
 
        location /quick-report-web/api/ {
            proxy_pass http://zxytest.zhixueyun.com/;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }
        location /static/ {
            proxy_pass http://zxytest.zhixueyun.com/static/;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }
        location /quick-report-web/compute/ {
            proxy_pass http://zxytest.zhixueyun.com/compute/;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }
        location /quick-report-web/reportInfo/ {
            proxy_pass http://zxytest.zhixueyun.com/reportInfo/;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }
        location /quick-report {
            proxy_pass http://zxytest.zhixueyun.com;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }
 
        location /node/api/v1/ {
            proxy_pass http://10.47.92.186:31186/;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
       location /logs
       {
          root /app/nginx/html/;
          autoindex on;
          autoindex_exact_size on;
          autoindex_localtime on;
          auth_basic "secret";
          auth_basic_user_file /app/nginx/conf/.logs_passwd.db;
       }
       location ~/zxy-scorm {
           proxy_redirect off;
           proxy_set_header Host $host;
           proxy_set_header X-Real-Ip $http_x_forwarded_for;
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
           proxy_pass http://zxy-scorm_address;
        }
       location ^~ /scorm-unzip {
           proxy_redirect off;
           proxy_set_header Host $host;
           proxy_set_header X-Real-Ip $http_x_forwarded_for;
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
           proxy_pass http://zxy-scorm_address;
        }
      location ^~ /demo {
           proxy_redirect off;
           proxy_set_header Host $host;
           proxy_set_header X-Real-Ip $http_x_forwarded_for;
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
           proxy_pass http://zxy-scorm_address;
        }
      location ^~ /videojs {
           proxy_redirect off;
           proxy_set_header Host $host;
           proxy_set_header X-Real-Ip $http_x_forwarded_for;
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
           proxy_pass http://zxy-scorm_address;
        }
      location /admin/default/M00 {
           alias /app/content/http/data/default/M00;
        }
      location ~^/default/M00/.*(?<!\.mp4|/)$ {
              root /app/content/http/data/;
              ngx_fastdfs_module;
      }
      location ~^/default/M00/.*\.(mp4)$ {
             mp4;
      }
      error_page 500 404 /404.html;
        location = /404.html {
              root /app/nginx/html;
              internal;
        }
      error_page 400 =200 @400
      location @400 
        root /app/content/http/data;
     }
        location /cloud {
            root /app/nginx/html;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
 
        location /api/v1/human {
            proxy_pass http://zxytest.zhixueyun.com;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
        location /api/v1/help-center {
            proxy_pass http://zxytest.zhixueyun.com;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
        location /api/v1/history {
            proxy_set_header X-Forwarded-Scheme $scheme;
            proxy_pass http://zxytest.zhixueyun.com;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
        location /api/v1/system {
            proxy_pass http://zxytest.zhixueyun.com;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
        location /api/v1/message {
            proxy_pass http://zxytest.zhixueyun.com;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
        location /api/v1/zxy-log {
            proxy_pass http://zxytest.zhixueyun.com;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
        location /api/v1/report {
            proxy_pass http://10.47.92.186:31166;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }
 
        location /api/v1/exam/ws {
            proxy_pass http://zxytest.zhixueyun.com;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }
        location /api/v1/exam {
            proxy_pass http://zxytest.zhixueyun.com;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }
        location /api/v1/course-study {
            proxy_pass http://zxytest.zhixueyun.com;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
        location /api/v1/ask-bar {
            proxy_pass http://zxytest.zhixueyun.com;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
        location /api/v1/ask-bar/ws {
            proxy_pass http://zxytest.zhixueyun.com;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }
        location /api/v1/training {
            proxy_pass http://zxytest.zhixueyun.com;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
        location /api/v1/training/ws {
            proxy_pass http://zxytest.zhixueyun.com;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }
        location /api/v1/cloud-center {
            proxy_pass http://zxytest.zhixueyun.com;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
        location /api/v1/cloud-center/ws {
            proxy_pass http://zxytest.zhixueyun.com;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }
        location /api/v1/live {
            proxy_pass http://zxytest.zhixueyun.com;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
        location /ws/live/ {
            proxy_pass http://10.47.92.186:31192/;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $http_x_forwarded_for;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
}
}

 

posted @ 2020-06-02 23:27  $world  阅读(239)  评论(0编辑  收藏  举报