2017-08-26 69 views
2

所以我從一個cPanel移動到一個CentOS服務器,所有的文件加載正常。在移動的時候我發現我不能起到了圖像沒有擴展名,例如:Nginx - 提供沒有擴展名的圖片

domain.com/uploads/avatars/avatar_5.?dateline=1501944732 但在cPanel的是完美的罰款。在過去的幾個小時裏,我一直在篡改Nginx,編輯default.cnf和what-not。有任何想法嗎?

編輯:當前要顯示的錯誤是「404未找到」

server { 
listen  80; 
server_name domain; 

# note that these lines are originally from the "location /" block 
root /usr/share/nginx/html; 
server_tokens off; 
index index.php index.html index.htm; 
rewrite ^/forum-([0-9]+)\.html$ /forumdisplay.php?fid=$1; 
    rewrite ^/forum-([0-9]+)-page-([0-9]+)\.html$ /forumdisplay.php?fid=$1&page=$2; 
    rewrite ^/thread-([0-9]+)\.html$ /showthread.php?tid=$1; 
    rewrite ^/thread-([0-9]+)-page-([0-9]+)\.html$ /showthread.php?tid=$1&page=$2; 
    rewrite ^/thread-([0-9]+)-lastpost\.html$ /showthread.php?tid=$1&action=lastpost; 
    rewrite ^/thread-([0-9]+)-nextnewest\.html$ /showthread.php?tid=$1&action=nextnewest; 
    rewrite ^/thread-([0-9]+)-nextoldest\.html$ /showthread.php?tid=$1&action=nextoldest; 
    rewrite ^/thread-([0-9]+)-newpost\.html$ /showthread.php?tid=$1&action=newpost; 
    rewrite ^/thread-([0-9]+)-post-([0-9]+)\.html$ /showthread.php?tid=$1&pid=$2; 
    rewrite ^/post-([0-9]+)\.html$ /showthread.php?pid=$1; 
    rewrite ^/announcement-([0-9]+)\.html$ /announcements.php?aid=$1; 
    rewrite ^/user-([0-9]+)\.html$ /member.php?action=profile&uid=$1; 
    rewrite ^/calendar-([0-9]+)\.html$ /calendar.php?calendar=$1; 
    rewrite ^/calendar-([0-9]+)-year-([0-9]+)\.html$ /calendar.php?action=yearview&calendar=$1&year=$2; 
    rewrite ^/calendar-([0-9]+)-year-([0-9]+)-month-([0-9]+)\.html$ /calendar.php?calendar=$1&year=$2&month=$3; 
    rewrite ^/calendar-([0-9]+)-year-([0-9]+)-month-([0-9]+)-day-([0-9]+)\.html$ /calendar.php?action=dayview&calendar=$1&year=$2&month=$3&day=$4; 
    rewrite ^/calendar-([0-9]+)-week-(n?[0-9]+)\.html$ /calendar.php?action=weekview&calendar=$1&week=$2; 
    rewrite ^/event-([0-9]+)\.html$ /calendar.php?action=event&eid=$1; 

    location/{ 
     try_files $uri $uri/ =404; 
    } 
    error_page 404 /404.html; 
    error_page 500 502 503 504 /50x.html; 
    location = /50x.html { 
     root /usr/share/nginx/html; 
    } 

    location ~ \.php$ { 
     try_files $uri =404; 
     fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; 
     fastcgi_index index.php; 
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
     include fastcgi_params; 
    } 
    location ~ /(upload/avatars) { 
    allow all; 
} 
    location ~* \.(jpg|jpeg|gif|png|css|ico|xml)$ { 
    access_log  off; 
    log_not_found  off; 
    expires   360d; 
     } 
} 

我也有原來的配置,如果我需要恢復。從舊的cPanel(阿帕奇)

的.htaccess

RewriteOptions inherit 
RewriteEngine on 

# Some hosts require RewriteBase to make RewriteRules work. 
RewriteBase/

# Google SEO workaround for search.php highlights: 
# Make this rule the first rewrite rule in your .htaccess! 
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ 
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ 
RewriteRule ^([^&]*)&(.*)$ http://realforums.net/$1?$2 [L,QSA,R=301] 

# Google SEO Sitemap: 
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ 
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ 
RewriteRule ^sitemap\-([^./]+)\.xml$ misc.php?google_seo_sitemap=$1 [L,QSA,NC] 

Options -MultiViews +FollowSymlinks -Indexes 

# 
# If mod_security is enabled, attempt to disable it. 
# - Note, this will work on the majority of hosts but on 
# MediaTemple, it is known to cause random Internal Server 
# errors. For MediaTemple, please remove the block below 
# 
<IfModule mod_security.c> 
    # Turn off mod_security filtering. 
    SecFilterEngine Off 

    # The below probably isn't needed, but better safe than sorry. 
    SecFilterScanPOST Off 
</IfModule> 

# 
# MyBB "search engine friendly" URL rewrites 
# - Note, for these to work with MyBB please make sure you have 
# the setting enabled in the Admin CP and you have this file 
# named .htaccess 
# 
<IfModule mod_rewrite.c> 
    RewriteEngine on 
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ 
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ 
    RewriteRule ^forum-([0-9]+)\.html$ forumdisplay.php?fid=$1 [L,QSA] 
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ 
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ 
    RewriteRule ^forum-([0-9]+)-page-([0-9]+)\.html$ forumdisplay.php?fid=$1&page=$2 [L,QSA] 

RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ 
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ 
    RewriteRule ^thread-([0-9]+)\.html$ showthread.php?tid=$1 [L,QSA] 
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ 
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ 
    RewriteRule ^thread-([0-9]+)-page-([0-9]+)\.html$ showthread.php?tid=$1&page=$2 [L,QSA] 
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ 
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ 
    RewriteRule ^thread-([0-9]+)-lastpost\.html$ showthread.php?tid=$1&action=lastpost [L,QSA] 
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ 
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ 
    RewriteRule ^thread-([0-9]+)-nextnewest\.html$ showthread.php?tid=$1&action=nextnewest [L,QSA] 
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ 
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ 
    RewriteRule ^thread-([0-9]+)-nextoldest\.html$ showthread.php?tid=$1&action=nextoldest [L,QSA] 
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ 
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ 
    RewriteRule ^thread-([0-9]+)-newpost\.html$ showthread.php?tid=$1&action=newpost [L,QSA] 
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ 
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ 
    RewriteRule ^thread-([0-9]+)-post-([0-9]+)\.html$ showthread.php?tid=$1&pid=$2 [L,QSA] 

RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ 
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ 
    RewriteRule ^post-([0-9]+)\.html$ showthread.php?pid=$1 [L,QSA] 

RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ 
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ 
    RewriteRule ^announcement-([0-9]+)\.html$ announcements.php?aid=$1 [L,QSA] 

RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ 
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ 
    RewriteRule ^user-([0-9]+)\.html$ member.php?action=profile&uid=$1 [L,QSA] 

RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ 
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ 
    RewriteRule ^calendar-([0-9]+)\.html$ calendar.php?calendar=$1 [L,QSA] 
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ 
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ 
    RewriteRule ^calendar-([0-9]+)-year-([0-9]+)-month-([0-9]+)\.html$ calendar.php?calendar=$1&year=$2&month=$3 [L,QSA] 
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ 
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ 
    RewriteRule ^calendar-([0-9]+)-year-([0-9]+)-month-([0-9]+)-day-([0-9]+)\.html$ calendar.php?action=dayview&calendar=$1&year=$2&month=$3&day=$4 [L,QSA] 
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ 
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ 
    RewriteRule ^calendar-([0-9]+)-week-(n?[0-9]+)\.html$ calendar.php?action=weekview&calendar=$1&week=$2 [L,QSA] 

RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ 
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ 
    RewriteRule ^event-([0-9]+)\.html$ calendar.php?action=event&eid=$1 [L,QSA] 

    <IfModule mod_env.c> 
     SetEnv SEO_SUPPORT 1 
    </IfModule> 
</IfModule> 

# 
# If Apache is compiled with built in mod_deflade/GZIP support 
# then GZIP Javascript, CSS, HTML and XML so they're sent to 
# the client faster. 
# 
<IfModule mod_deflate.c> 
    AddOutputFilterByType DEFLATE text/css text/html application/xhtml+xml text/xml application/xml text/plain text/x-component application/javascript application/x-javascript application/rss+xml application/atom+xml application/json application/manifest+json application/x-web-app-manifest+json application/vnd.ms-fontobject application/font-sfnt application/font-woff application/font-woff2 image/svg+xml image/x-icon 
</IfModule> 

# Note: You are able to choose a different name in the Admin CP. If you've done that you need to change it here too 
<Files "error.log"> 
    Order Deny,Allow 
    Deny from all 
</Files> 

RewriteOptions inherit 
RewriteEngine on 

# Some hosts require RewriteBase to make RewriteRules work. 
RewriteBase/

# Google SEO workaround for search.php highlights: 
# Make this rule the first rewrite rule in your .htaccess! 
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ 
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ 
RewriteRule ^([^&]*)&(.*)$ http://realforums.net/$1?$2 [L,QSA,R=301] 

# Google SEO Sitemap: 
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ 
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ 
RewriteRule ^sitemap\-([^./]+)\.xml$ misc.php?google_seo_sitemap=$1 [L,QSA,NC] 

Options -MultiViews +FollowSymlinks -Indexes 

# 
# If mod_security is enabled, attempt to disable it. 
# - Note, this will work on the majority of hosts but on 
# MediaTemple, it is known to cause random Internal Server 
# errors. For MediaTemple, please remove the block below 
# 
<IfModule mod_security.c> 
    # Turn off mod_security filtering. 
    SecFilterEngine Off 

    # The below probably isn't needed, but better safe than sorry. 
    SecFilterScanPOST Off 
</IfModule> 

# 
# MyBB "search engine friendly" URL rewrites 
# - Note, for these to work with MyBB please make sure you have 
# the setting enabled in the Admin CP and you have this file 
# named .htaccess 
# 
<IfModule mod_rewrite.c> 
    RewriteEngine on 
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ 
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ 
    RewriteRule ^forum-([0-9]+)\.html$ forumdisplay.php?fid=$1 [L,QSA] 
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ 
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ 
    RewriteRule ^forum-([0-9]+)-page-([0-9]+)\.html$ forumdisplay.php?fid=$1&page=$2 [L,QSA] 

RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ 
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ 
    RewriteRule ^thread-([0-9]+)\.html$ showthread.php?tid=$1 [L,QSA] 
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ 
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ 
    RewriteRule ^thread-([0-9]+)-page-([0-9]+)\.html$ showthread.php?tid=$1&page=$2 [L,QSA] 
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ 
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ 
    RewriteRule ^thread-([0-9]+)-lastpost\.html$ showthread.php?tid=$1&action=lastpost [L,QSA] 
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ 
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ 
    RewriteRule ^thread-([0-9]+)-nextnewest\.html$ showthread.php?tid=$1&action=nextnewest [L,QSA] 
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ 
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ 
    RewriteRule ^thread-([0-9]+)-nextoldest\.html$ showthread.php?tid=$1&action=nextoldest [L,QSA] 
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ 
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ 
    RewriteRule ^thread-([0-9]+)-newpost\.html$ showthread.php?tid=$1&action=newpost [L,QSA] 
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ 
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ 
    RewriteRule ^thread-([0-9]+)-post-([0-9]+)\.html$ showthread.php?tid=$1&pid=$2 [L,QSA] 

RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ 
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ 
    RewriteRule ^post-([0-9]+)\.html$ showthread.php?pid=$1 [L,QSA] 

RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ 
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ 
    RewriteRule ^announcement-([0-9]+)\.html$ announcements.php?aid=$1 [L,QSA] 

RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ 
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ 
    RewriteRule ^user-([0-9]+)\.html$ member.php?action=profile&uid=$1 [L,QSA] 

RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ 
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ 
    RewriteRule ^calendar-([0-9]+)\.html$ calendar.php?calendar=$1 [L,QSA] 
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ 
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ 
    RewriteRule ^calendar-([0-9]+)-year-([0-9]+)-month-([0-9]+)\.html$ calendar.php?calendar=$1&year=$2&month=$3 [L,QSA] 
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ 
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ 
    RewriteRule ^calendar-([0-9]+)-year-([0-9]+)-month-([0-9]+)-day-([0-9]+)\.html$ calendar.php?action=dayview&calendar=$1&year=$2&month=$3&day=$4 [L,QSA] 
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ 
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ 
    RewriteRule ^calendar-([0-9]+)-week-(n?[0-9]+)\.html$ calendar.php?action=weekview&calendar=$1&week=$2 [L,QSA] 

RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ 
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ 
    RewriteRule ^event-([0-9]+)\.html$ calendar.php?action=event&eid=$1 [L,QSA] 

    <IfModule mod_env.c> 
     SetEnv SEO_SUPPORT 1 
    </IfModule> 
</IfModule> 

# 
# If Apache is compiled with built in mod_deflade/GZIP support 
# then GZIP Javascript, CSS, HTML and XML so they're sent to 
# the client faster. 
# 
<IfModule mod_deflate.c> 
    AddOutputFilterByType DEFLATE text/css text/html application/xhtml+xml text/xml application/xml text/plain text/x-component application/javascript application/x-javascript application/rss+xml application/atom+xml application/json application/manifest+json application/x-web-app-manifest+json application/vnd.ms-fontobject application/font-sfnt application/font-woff application/font-woff2 image/svg+xml image/x-icon 
</IfModule> 

# Note: You are able to choose a different name in the Admin CP. If you've done that you need to change it here too 
<Files "error.log"> 
    Order Deny,Allow 
    Deny from all 
</Files> 

我換成Apache的nginx的的.htaccess:

# Note: You are able to choose a different name in the Admin CP. If you've done that you need to change it here too 
location ~ /error.log 
{ 
    deny all; 
} 

# Note: You are able to rename the admin directory. If you've done that, you need to change it here too 
location /admin/backups { 
    deny all; 
} 

# Google SEO workaround for search.php highlights: 
    # Make this rule the first rewrite rule in your .htaccess! 
    rewrite ^/MyBB/([^&]*)&(.*)$ http://yoursite/MyBB/$1?$2 permanent; 

    # Google SEO Sitemap: 
    rewrite ^/MyBB/((?i)sitemap-([^./]+)\.xml)$ /MyBB/misc.php?google_seo_sitemap=$2; 
rewrite ^/forum-([0-9]+).html$ /forumdisplay.php?fid=$1 last; 
rewrite ^/forum-([0-9]+)-page-([0-9]+).html$ /forumdisplay.php?fid=$1&page=$2 last; 
rewrite ^/thread-([0-9]+).html$ /showthread.php?tid=$1 last; 
rewrite ^/thread-([0-9]+)-page-([0-9]+).html$ /showthread.php?tid=$1&page=$2 last; 
rewrite ^/thread-([0-9]+)-lastpost.html$ /showthread.php?tid=$1&action=lastpost last; 
rewrite ^/thread-([0-9]+)-nextnewest.html$ /showthread.php?tid=$1&action=nextnewest last; 
rewrite ^/thread-([0-9]+)-nextoldest.html$ /showthread.php?tid=$1&action=nextoldest last; 
rewrite ^/thread-([0-9]+)-newpost.html$ /showthread.php?tid=$1&action=newpost last; 
rewrite ^/thread-([0-9]+)-post-([0-9]+).html$ /showthread.php?tid=$1&pid=$2 last; 
rewrite ^/post-([0-9]+).html$ /showthread.php?pid=$1 last; 
rewrite ^/announcement-([0-9]+).html$ /announcements.php?aid=$1 last; 
rewrite ^/user-([0-9]+).html$ /member.php?action=profile&uid=$1 last; 
rewrite ^/calendar-([0-9]+).html$ /calendar.php?calendar=$1 last; 
rewrite ^/calendar-([0-9]+)-year-([0-9]+)-month-([0-9]+).html$ /calendar.php?calendar=$1&year=$2&month=$3 last; 
rewrite ^/calendar-([0-9]+)-year-([0-9]+)-month-([0-9]+)-day-([0-9]+).html$ /calendar.php?action=dayview&calendar=$1&year=$2&month=$3&day=$4 last; 
rewrite ^/calendar-([0-9]+)-week-(n?[0-9]+).html$ /calendar.php?action=weekview&calendar=$1&week=$2 last; 
rewrite ^/event-([0-9]+).html$ /calendar.php?action=event&eid=$1 last; 

回答

0

默認的nginx將基於擴展添加content-type。但在你的情況下,當擴展名丟失,它會錯過添加內容類型。所以,你需要添加一個自己

location ~ /(upload/avatars) { 
    allow all; 
    add_header Content-Type image/png; 
} 

如果存儲PNG或image/jpeg

編輯-1

看來你應該設置default_type指令

location ~ /(upload/avatars) { 
    allow all; 
    default_type image/png; 
} 

編輯2

要在末尾,仍然服務器上的文件使用擺脫.

location /uploads/avatars/ { 
    default_type image/png; 
    try_files $uri @without-dot; 
} 

location @without-dot { 
    rewrite ^/(.*)\.$ /$1; 
} 

編輯-3

要在年底擺脫.,仍然服務器上的文件改變現有的位置塊

location ~ /(upload/avatars) { 
    allow all; 
    default_type image/png; 
    try_files $uri @without-dot; 
} 

location @without-dot { 
    rewrite ^/(.*)\.$ /$1; 
} 
+0

註釋不適用於擴展討論或調試會話;這個對話已經[轉移到聊天](http://chat.stackoverflow.com/rooms/152951/discussion-on-answer-by-tarun-lalwani-nginx-serving-images-without-extensions)。如果您仍然遇到問題,請使用相關信息更新您的問題。 –

+0

@CodyGray,我猜如果<20的聲望不能加入聊天? –

+1

評論自動轉移到聊天會授予涉及該特權的用戶,而不管他們的聲譽如何。他們無法在其他地方聊天,但他們可以在這個房間聊天。 –