Я работаю на виртуальной машине в Debian 6. У меня есть nginx впереди для обслуживания статических файлов ('jpg, png, css, js ...) и apache для запуска скрипта.
Но у меня есть проблема, мои файлы ресурсов делают ошибку 404.
Моя конфигурация nginx:
server {
listen 80;
server_name mysite ;
#access_log /var/log/nginx/access.mysite.log;
#error_log /var/log/nginx/error.mysite.log;
# Les requêtes sont transmises au processus Apache écoutant en local sur le port 81
location / {
proxy_pass http://127.0.0.1:81/;
include /etc/nginx/proxy.conf;
}
# On remap sur la racine du domaine
if ($host != "mysite"){
rewrite ^(.*)$ http://mysite$1 permanent;
break;
}
# On distribue les fichiers statiques directement
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|txt|srt|swf)$ {
root /home/php/mysite/public;
#access_log /var/log/nginx/access.mysite.log;
#error_log /var/log/nginx/error.mysite.log;
expires 1d;
}
}
И моя конфигурация apache:
<VirtualHost *>
DocumentRoot /home/php/mysite/public
ServerName mysite
PassengerRoot /usr/local/lib/ruby/gems/1.9.1/gems/passenger-3.0.9
PassengerRuby /usr/local/bin/ruby
RailsEnv development
#ServerAlias
<Directory /home/php/mysite/public>
#Conf Standard
AllowOverride All
Order allow,deny
Allow from all
</Directory>
TransferLog /dev/null
</VirtualHost>
My development.ru
MySite::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true
# Show full error reports and disable caching
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = false
# Print deprecation notices to the Rails logger
config.active_support.deprecation = :log
# Only use best-standards-support built into browsers
config.action_dispatch.best_standards_support = :builtin
# Do not compress assets
config.assets.compress = false
# Expands the lines which load the assets
config.assets.debug = true
end
Я пользуюсь рельсами 3.1.1 с пассажиром.Я думаю, что это действительно проблема nginx, потому что когда я перехожу на http://mysite:81 (то есть непосредственно на apache), все работает нормально.
Спасибо за помощь.