2017-11-11 155 views
-5

我有最奇怪的技術問題。雖然我的網站在開發過程中工作正常,並且過去在生產環境中工作正常,但在最後一次構建過程中,它已經莫名其妙地停止了對靜態資產的識別,並且正在將老版本的favicon用於討價還價。我甚至試圖重新制作整個回購,但我遇到了完全相同的問題。舊的favicon甚至不存在於回購中。服務器無法看到用Brunch編譯的靜態資產(Phoenix Framework)

我在牛仔服務器進程的前一個nginx的反向代理,具有以下配置:

upstream phoenix { 
     server 127.0.0.1:4000; 
} 


# Default server configuration 
# 

server { 
     listen  80; 
     server_name haaksploits.com www.haaksploits.com; 
     return  301 https://$server_name$request_uri; 
} 

server { 
    # SSL configuration 
    listen 443 ssl http2; 
    listen [::]:443 ssl http2; 

     rewrite ^/(.*)/$ /$1 permanent; 

     server_name haaksploits.com wwww.haaksploits.com; 

     ssl_certificate /etc/letsencrypt/live/haaksploits.com/fullchain.pem; 
     ssl_certificate_key /etc/letsencrypt/live/haaksploits.com/privkey.pem; 
     ssl_dhparam /etc/nginx/ssl/dhparam.pem; 

     ssl_stapling on; 
     ssl_stapling_verify on; 

     access_log /var/log/nginx/sub.log combined; 

    root /var/www/haaksploits.com/html; 

    # Add index.php to the list if you are using PHP 
    index index.html index.php index.htm; 

    location/{ 
       allow all; 

       # Proxy Headers 
       proxy_http_version 1.1; 
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
       proxy_set_header Host $http_host; 
       proxy_set_header X-Cluster-Client-Ip $remote_addr; 

       # WebSockets 
       proxy_set_header Upgrade $http_upgrade; 
       proxy_set_header Connection "upgrade"; 

       proxy_pass http://phoenix; 

       include /etc/nginx/mime.types; 
    } 

     location ~ /.well-known { 
       allow all; 
     } 

     # Enable browser caching 

     location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ { 
       expires 365d; 
     } 

     location ~* \.(pdf)$ { 
       expires 10d; 
     } 

    # pass PHP scripts to FastCGI server 

    location ~ \.php$ { 
     include snippets/fastcgi-php.conf; 

     # With php-fpm (or other unix sockets): 
     fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; 
    } 

} 

正如你所看到的,我已經啓用緩存,但我試過這個設置爲一秒並沒有任何幫助,並且無論如何我在之前上傳了新的圖標,因爲它沒有問題。我mix.exs:

defmodule Haaksploits.Mixfile do 
    use Mix.Project 

    def project do 
    [ 
     app: :haaksploits, 
     version: "0.2.3", 
     elixir: "~> 1.4", 
     elixirc_paths: elixirc_paths(Mix.env), 
     compilers: [:phoenix, :gettext] ++ Mix.compilers, 
     start_permanent: Mix.env == :prod, 
     aliases: aliases(), 
     deps: deps() 
    ] 
    end 

    def application do 
    [ 
     mod: {Haaksploits.Application, []}, 
     extra_applications: [:logger, :runtime_tools, :ueberauth, :ueberauth_google] 
    ] 
    end 

    defp elixirc_paths(:test), do: ["lib", "test/support"] 
    defp elixirc_paths(_),  do: ["lib"] 

    defp deps do 
    [ 
     {:phoenix, "~> 1.3.0"}, 
     {:phoenix_pubsub, "~> 1.0"}, 
     {:phoenix_ecto, "~> 3.2"}, 
     {:postgrex, ">= 0.0.0"}, 
     {:phoenix_html, "~> 2.10"}, 
     {:phoenix_live_reload, "~> 1.0", only: :dev}, 
     {:gettext, "~> 0.11"}, 
     {:cowboy, "~> 1.0"}, 
     {:ueberauth_google, "~> 0.2"}, 
     {:ja_serializer, "~> 0.11.2"}, 
     {:guardian, "~> 0.14.2"} 
    ] 
    end 

    defp aliases do 
    [ 
     "ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"], 
     "ecto.reset": ["ecto.drop", "ecto.setup"], 
     "test": ["ecto.create --quiet", "ecto.migrate", "test"] 
    ] 
    end 
end 

而且我prod.exs:

use Mix.Config 

config :haaksploits, HaaksploitsWeb.Endpoint, 
    http: [port: 4000], 
    url: [host: "haaksploits.com", port: 80], 
    cache_static_manifest: "priv/static/cache_manifest.json", 
    server: true, 
    code_reloader: false 

config :logger, level: :info 

import_config "prod.secret.exs" 

我能想到的唯一的另一件事是,在最後的構建之前,發生問題出現了一個錯誤,說酒廠是錯過了,所以我重新添加它以完成構建。我此後刪除了Distillery和Edeliver,因爲此刻我並不需要它們,雖然問題沒有消失,但我不知道這是否對文件做了些什麼,導致服務器查看錯誤資產的位置。

如果是這樣的話,我真正需要的是知道Distillery正在尋找這些文件的位置,以及如何讓Phoenix重新找到適合靜態資產的位置。或者,如果以某種方式阻止訪問,則允許訪問文件。

當我查看/ priv/static時,所有文件都是它們應該在的位置。後

我的機器上測試沒有nginx的,它似乎並沒有成爲鳳凰/酒廠的問題,而是事做Nginx的配置。因此,也許一個緩存的問題:

更新所有........

更新:

如此,因爲它當你的nginx的方程完全靜止失敗是沒有問題的。使用早午餐或釀酒廠構建發行版時,它也失敗,但僅在兩個生產服務器(一個Debian,一個Ubuntu)上,而不是在我的開發Mac上。我正在嘗試在我的開發環境中構建,然後將構建的tarball手動掃描到生產環境。

更新:

壓縮包解失敗,因爲開發機及生產機器之間的結構上的差異。試圖使用edeliver來規避。

更新:

似乎是工作的罰款時,該過程從IP地址直接訪問,所以離開了我能想到的唯一的事情就是這件事情的The域名解析階段之間的腳麻,和訪問靜態資產。留下edeliver解決方案,而是嘗試使用Cloudflare,看看是否有幫助。

回答

-2

這個問題的源代碼(至少對於我的主服務器來說,似乎有另外一個問題導致了另一個錯誤,這很奇怪,但是meh)最終導致SSL證書出錯,導致訪問被阻止到只有一些內容(???)。

我清除了所有的nginx設置,刪除了所有certbot SSL設置,爲Cloudflare簽名並啓用了SSL服務。這解決了這個問題。

相關問題