211 lines
		
	
	
		
			7.1 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			211 lines
		
	
	
		
			7.1 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
server {
 | 
						||
    listen       80;
 | 
						||
    listen  [::]:80;
 | 
						||
    server_name  localhost;
 | 
						||
 | 
						||
    # ssl
 | 
						||
    # listen       443 ssl;
 | 
						||
    # server_name  localhost;
 | 
						||
 | 
						||
    # ssl_certificate /etc/nginx/certs/cert.pem; # 证书文件路径
 | 
						||
    # ssl_certificate_key /etc/nginx/certs/key.pem; # 私钥文件路径
 | 
						||
 
 | 
						||
    # ssl_session_cache shared:SSL:1m;
 | 
						||
    # ssl_session_timeout  10m;
 | 
						||
    # ssl_ciphers HIGH:!aNULL:!MD5;
 | 
						||
    # ssl_prefer_server_ciphers on;
 | 
						||
 | 
						||
 | 
						||
 | 
						||
    #access_log  /var/log/nginx/host.access.log  main;
 | 
						||
 | 
						||
    location / {
 | 
						||
        root   /usr/share/nginx/html;
 | 
						||
        index  index.html index.htm;
 | 
						||
        # 下面这行可以解决vue网页刷新后404的问题,但会将所有不存在的url转到index.html上
 | 
						||
        try_files   $uri    $uri/   /index.html last;
 | 
						||
    }
 | 
						||
 | 
						||
    # 反向代理示例
 | 
						||
    # 将/api/的请求转到127.0.0.1:8787
 | 
						||
    #
 | 
						||
    # location /api/ {
 | 
						||
    #     proxy_next_upstream http_502 http_504 error timeout invalid_header;
 | 
						||
    #     proxy_pass http://127.0.0.1:8787/;
 | 
						||
    #     proxy_set_header Host $host;
 | 
						||
    #     proxy_set_header X-Real-IP $remote_addr;
 | 
						||
    #     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 | 
						||
    #     proxy_set_header X-Forwarded-Proto $scheme;
 | 
						||
    # }
 | 
						||
 | 
						||
    location /pgadmin/ {  
 | 
						||
        proxy_pass http://pgadmin:80/;  
 | 
						||
        proxy_set_header Host $host;  
 | 
						||
        proxy_set_header X-Real-IP $remote_addr;  
 | 
						||
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;  
 | 
						||
        proxy_set_header X-Forwarded-Proto $scheme;  
 | 
						||
        proxy_set_header X-Script-Name /pgadmin;
 | 
						||
        sub_filter '="/' '="/pgadmin/';  # 将资源引用路径中的=/替换为=/pgadmin/
 | 
						||
        sub_filter_once off;
 | 
						||
    }
 | 
						||
 | 
						||
    # location /kibana/ {  
 | 
						||
    #     proxy_pass http://kibana:5601/;  # Kibana 运行的地址和端口  
 | 
						||
    #     proxy_http_version 1.1;  
 | 
						||
    #     proxy_set_header Upgrade $http_upgrade;  
 | 
						||
    #     proxy_set_header Connection 'upgrade';  
 | 
						||
    #     proxy_set_header Host $host;  
 | 
						||
    #     proxy_cache_bypass $http_upgrade;  
 | 
						||
 | 
						||
    #     # 为了正确处理 Kibana 的资源加载,还需要拼接 URI  
 | 
						||
    #     proxy_redirect http://kibana:5601/ /kibana/;  
 | 
						||
    # }  
 | 
						||
 | 
						||
    location /portainer/ {  
 | 
						||
        rewrite ^/portainer/(.*) /$1 break;
 | 
						||
        proxy_set_header Host $http_host;
 | 
						||
        proxy_set_header X-Real-IP $remote_addr;
 | 
						||
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 | 
						||
        proxy_set_header X-Forwarded-Proto $scheme;
 | 
						||
        proxy_set_header X-NginX-Proxy true;
 | 
						||
 | 
						||
        # This is necessary to pass the correct IP to be hashed
 | 
						||
        real_ip_header X-Real-IP;
 | 
						||
 | 
						||
        proxy_connect_timeout 300;
 | 
						||
 | 
						||
        proxy_http_version 1.1;
 | 
						||
        proxy_set_header Upgrade $http_upgrade;
 | 
						||
        proxy_set_header Connection "upgrade";
 | 
						||
        # proxy_set_header Origin '';
 | 
						||
 | 
						||
        chunked_transfer_encoding off;
 | 
						||
 | 
						||
        proxy_pass http://portainer:9000; # This uses the upstream directive definition to load balance
 | 
						||
 | 
						||
        sub_filter '="/' '="/portainer/';  # 将资源引用路径中的=/替换为=/portainer/
 | 
						||
        sub_filter_once off;
 | 
						||
    }
 | 
						||
 | 
						||
    location /mongo/ {  
 | 
						||
        rewrite ^/mongo/(.*) /$1 break;
 | 
						||
        proxy_pass http://mongo-express:8081/;  
 | 
						||
        proxy_set_header Host $http_host;
 | 
						||
        proxy_set_header X-Real-IP $remote_addr;
 | 
						||
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 | 
						||
        proxy_set_header X-Forwarded-Proto $scheme;
 | 
						||
        proxy_set_header X-NginX-Proxy true;
 | 
						||
 | 
						||
        # This is necessary to pass the correct IP to be hashed
 | 
						||
        real_ip_header X-Real-IP;
 | 
						||
 | 
						||
        proxy_connect_timeout 300;
 | 
						||
 | 
						||
        # To support websockets
 | 
						||
        proxy_http_version 1.1;
 | 
						||
        proxy_set_header Upgrade $http_upgrade;
 | 
						||
        proxy_set_header Connection "upgrade";
 | 
						||
        # Some environments may encounter CORS errors (Kubernetes + Nginx Ingress)
 | 
						||
        # Uncomment the following line to set the Origin request to an empty string
 | 
						||
        # proxy_set_header Origin '';
 | 
						||
 | 
						||
        chunked_transfer_encoding off;
 | 
						||
        sub_filter '="/' '="/mongo/';  # 将资源引用路径中的=/替换为=/mongo/
 | 
						||
        sub_filter_once off;
 | 
						||
    }
 | 
						||
 | 
						||
    location /minio/ {
 | 
						||
        rewrite ^/minio/(.*) /$1 break;
 | 
						||
        proxy_set_header Host $http_host;
 | 
						||
        proxy_set_header X-Real-IP $remote_addr;
 | 
						||
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 | 
						||
        proxy_set_header X-Forwarded-Proto $scheme;
 | 
						||
        proxy_set_header X-NginX-Proxy true;
 | 
						||
 | 
						||
        # This is necessary to pass the correct IP to be hashed
 | 
						||
        real_ip_header X-Real-IP;
 | 
						||
 | 
						||
        proxy_connect_timeout 300;
 | 
						||
 | 
						||
        # To support websockets in MinIO versions released after January 2023
 | 
						||
        proxy_http_version 1.1;
 | 
						||
        proxy_set_header Upgrade $http_upgrade;
 | 
						||
        proxy_set_header Connection "upgrade";
 | 
						||
        # Some environments may encounter CORS errors (Kubernetes + Nginx Ingress)
 | 
						||
        # Uncomment the following line to set the Origin request to an empty string
 | 
						||
        # proxy_set_header Origin '';
 | 
						||
 | 
						||
        chunked_transfer_encoding off;
 | 
						||
 | 
						||
        proxy_pass http://minio:9001; # This uses the upstream directive definition to load balance
 | 
						||
 | 
						||
        sub_filter '="/' '="/minio/';  # 将资源引用路径中的=/替换为=/minio/
 | 
						||
        sub_filter_once off;
 | 
						||
   }
 | 
						||
 | 
						||
    location /rabbitmq/ {
 | 
						||
        rewrite ^/rabbitmq/(.*) /$1 break;
 | 
						||
        proxy_set_header Host $http_host;
 | 
						||
        proxy_set_header X-Real-IP $remote_addr;
 | 
						||
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 | 
						||
        proxy_set_header X-Forwarded-Proto $scheme;
 | 
						||
        proxy_set_header X-NginX-Proxy true;
 | 
						||
 | 
						||
        # This is necessary to pass the correct IP to be hashed
 | 
						||
        real_ip_header X-Real-IP;
 | 
						||
 | 
						||
        proxy_connect_timeout 300;
 | 
						||
 | 
						||
        # To support websockets
 | 
						||
        proxy_http_version 1.1;
 | 
						||
        proxy_set_header Upgrade $http_upgrade;
 | 
						||
        proxy_set_header Connection "upgrade";
 | 
						||
        # Some environments may encounter CORS errors (Kubernetes + Nginx Ingress)
 | 
						||
        # Uncomment the following line to set the Origin request to an empty string
 | 
						||
        # proxy_set_header Origin '';
 | 
						||
 | 
						||
        chunked_transfer_encoding off;
 | 
						||
 | 
						||
        proxy_pass http://rabbitmq:15672; # This uses the upstream directive definition to load balance
 | 
						||
 | 
						||
        sub_filter '="/' '="/rabbitmq/';  # 将资源引用路径中的=/替换为=/rabbitmq/
 | 
						||
        sub_filter_once off;
 | 
						||
   }
 | 
						||
 | 
						||
    error_page  404              /404.html;
 | 
						||
    location = /404.html {
 | 
						||
        root   /usr/share/nginx/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;
 | 
						||
    #}
 | 
						||
}
 | 
						||
 |