• nginx 搭建静态网页服务,不同的前缀进入不同的静态文件路径


    
    server {
                listen 5555 default_server;
      listen [::]:5555 default_server;
        server_name _;
    
            proxy_set_header X-Forwarded-Host $http_host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header X-Real-IP $remote_addr;
    
            # rewrite ^(.*)$ https://www.odoo.com/;
                location / {
                    root /root/workspace/build; # 设置静态文件所在的根目录
                    autoindex on;
                    autoindex_exact_size off;
                    autoindex_localtime on;
         # proxy_pass https://www.odoo.com/;
                    # proxy_pass http://kk2w.cc/;
                    proxy_set_header X-Forwarded-Host $http_host;
                    proxy_set_header X-Real-IP $remote_addr;
                    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                    client_max_body_size 20m;
    
      }
    
    }
    
    

    使用不同的url前缀来访问不同的文件路径,我的配置文件如下:

    注意根路径需要使用alias 而不是 root

    server {
    	listen 8888 default_server;
      	listen [::]:8888 default_server;
        	server_name odoo.abc.xyz;
    
            proxy_set_header X-Forwarded-Host $http_host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header X-Real-IP $remote_addr;
    
    	# rewrite ^(.*)$ https://www.odoo.com/;
    	location /odoo14/ {
    		alias /root/workspace/odoo14/build/;
    		autoindex on;
    		autoindex_exact_size off;
    		autoindex_localtime on;
    		 proxy_set_header X-Forwarded-Host $http_host;
                     proxy_set_header X-Real-IP $remote_addr;
                     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                     client_max_body_size 20m;
    
    	}
    	    location /odoo12/ {
    		alias /root/workspace/build/;
    		autoindex on;
    		autoindex_exact_size off;
    		autoindex_localtime on;
    	     # proxy_pass https://www.odoo.com/;
        		# proxy_pass http://kk2w.cc/;
                    proxy_set_header X-Forwarded-Host $http_host;
                    proxy_set_header X-Real-IP $remote_addr;
                    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                    client_max_body_size 20m;
    
      }
    
    }
    
  • 相关阅读:
    多行文字垂直居中效果(利用flex)
    Switch
    Scanner
    Method
    Recursion递归
    for
    if
    dowhile
    while
    DataType 数据类型
  • 原文地址:https://www.cnblogs.com/qianxunman/p/12739795.html
Copyright © 2020-2023  润新知