簡體   English   中英

Nginx上的https靜態內容

[英]https static content on NGINX

我已經從同事那里繼承了已經設置了NGINX的VPS的配置。 我目前可以通過http和https提供動態內容,但是當將https指定為連接類型時,不會加載靜態內容(例如圖像,javascript和css)(顯示為404)。

繼承了配置后,盡管我沒有嘗試NGINX自己的指南在http指令下將位置塊添加到nginx.conf,並指定了要使用的根目錄,但我不太確定從哪里開始。

http{
  include       /etc/nginx/mime.types;
  default_type  application/octet-stream;
  server_tokens off;
  ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    location / {
      root /var/www/;
    }
}

在禁用NGINX的情況下,我也會得到相同的行為,但是在同事的筆記中找不到關於其他可能提供內容的文檔。

任何朝着正確方向的指針將不勝感激!

nginx.conf

user              nginx;
worker_processes  1;
error_log         /var/log/nginx/error.log;
pid               /var/run/nginx.pid;

events {
    worker_connections  1024;
}



http {

    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;
    server_tokens off;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request "'
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    autoindex off;
    map $scheme $fastcgi_https { ## Detect when HTTPS is used
        default off;
        https on;
    }


client_header_timeout 3000;
client_body_timeout 3000;
fastcgi_read_timeout 3000;
client_max_body_size 32m;
fastcgi_buffers 8 128k;
fastcgi_buffer_size 128k;

    keepalive_timeout  10;

gzip  on;
gzip_http_version 1.1;
gzip_vary on;
gzip_comp_level 6;
gzip_proxied any;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript text/x-js;
gzip_buffers 16 8k;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
    # Load config files from the /etc/nginx/conf.d directory
    include /etc/nginx/conf.d/*.conf;

}

仔細研究一下,我發現NGINX一直在向x-accel-internal的服務器>>位置塊中添加命令。

通過將模板proxy.php從conf / templates / default / domain / service復制到custom / domain / service並注釋掉此命令,nginx在通過SSH重新創建配置文件后再次正確提供內容

/usr/local/psa/admin/bin/httpdmng --reconfigure-all
nginx -t && service nginx reload

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM