server {
    listen              443 ssl;
    server_name         fn.tianmu.cn;
    client_max_body_size 0;

    root                "/Users/zhaoqidong/PhpProjects/financial/public";
    error_log           "/Applications/MAMP/logs/nginx_ssl_error.log";

    ssl_certificate     "/Applications/MAMP/Library/OpenSSL/certs/fn.tianmu.cn.crt";
    ssl_certificate_key "/Applications/MAMP/Library/OpenSSL/certs/fn.tianmu.cn.key";
    ssl_session_cache   shared:SSL:10m;
    ssl_session_timeout 10m;
    ssl_session_tickets off;

    location / {
        try_files $uri $uri/ @proxy;
        index index.html index.php;
        autoindex off;
    }

    location @proxy {
        proxy_pass http://127.0.0.1:8888;
        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_http_version 1.1;
        proxy_read_timeout 360s;
        proxy_redirect off;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header REMOTE-HOST $remote_addr;
    }

    location /ws/ {
        proxy_pass http://127.0.0.1:8080;  # 将此地址替换为你的 WebSocket 服务器地址和端口
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        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 ~ \.php(/.*)*$ {
        try_files $uri =404;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include /Applications/MAMP/conf/nginx/fastcgi_params;
        include /Applications/MAMP/conf/nginx/fastcgi.conf;
        fastcgi_pass unix:/Applications/MAMP/Library/logs/fastcgi/nginxFastCGI_php7.4.33.sock;
    }

    location ~* \.(jpg|jpeg|png|gif|ico|css|js|html|woff|woff2|ttf|svg)$ {
        root "/Users/zhaoqidong/PhpProjects/financial/public";
        expires 30d;
        access_log off;
    }
}
Last modification:September 2, 2024
如果觉得我的文章对你有用,请随意赞赏