В laravel нужно добавить
Route::group(array('domain' => '{lang}.myapp.com'), function() {
Route::get('/', function($lang, $id) {
// ...
// Ваши роутеры
});});
В nginx добавить
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /var/www/laravel/public;
index index.php index.html index.htm;
server_name myapp.com .myapp.com;
try_files $uri $uri/ @rewrite;
location @rewrite {
rewrite ^/(.*)$ /index.php?_url=/$1;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
В итоге laravel обрабатывает запросы с myapp.com и со всех его под доменов.
UPD
Если nginx + apathe2
то
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /var/www/laravel/public;
index index.php index.html index.htm;
server_name myapp.com .myapp.com;
location / {
proxy_pass 127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_connect_timeout 120;
proxy_send_timeout 120;
proxy_read_timeout 180;
}
}
В Apache2
<VirtualHost *:8080>
ServerName myapp.com
DocumentRoot /var/www/laravel/public
ServerAlias *.myapp.com
SetEnv MY_LARAVEL_ENV "staging"
<Directory /var/www/laravel/public>
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
</Directory>
</VirtualHost>