linux nginx带前缀配置前后端https

user root;
worker_processes 1;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#pid logs/nginx.pid;

events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;

server {
listen 80;
server_name ip;

        return 301 https://$http_host$request_uri;

}

server {
listen 443 ssl;
server_name ip;
ssl_certificate tc.cer;
ssl_certificate_key tc.key;

ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;




location / {
        root /home/vue/20230327/dist;

             index index.html;
         try_files $uri $uri/ /index.html;
    # 其他的proxy配置
}

   location /water {
    # 将不带 frontend 的部分作为参数传递给后端应用程序
    rewrite ^/water(/.*)?$ $1 break;
    proxy_pass  http://ip;
    # 其他的proxy配置
}

location /water {

alias /home/vue/202303231/dist;

expires 1d;

index index.html;

autoindex on;

#}

            location ^~/static {
   alias  /home/vue/20230327/dist/static;

            expires  1d;
    index index.html;
autoindex on;

}

location  ^~/api {

             proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-Port $server_port;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
            proxy_pass http://ip:8081;
    }

}
}

你可能感兴趣的:(linux)