Как запустить 2 приложения на одном порту для nginx?
Поднимаю несколько сайтов на одной машине. Нашел конфиг с настройкой nginx:
server { listen 80 default; server_name site1.ru; location ~* \.(jpg|jpeg|gif|png|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|tar|wav|bmp|rtf|swf|ico|flv|txt|xml|docx|xlsx)$ { root /var/www/site1.ru; index index.html index.php; access_log off; expires 30d; error_page 404 = @fallback; proxy_cache_valid 404 1m; } location ~ /\.ht { deny all; } location / { proxy_pass 127.0.0.1:8080/; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-for $remote_addr; proxy_set_header Host $host; proxy_connect_timeout 60; proxy_send_timeout 90; proxy_read_timeout 90; proxy_redirect off; proxy_set_header Connection close; proxy_pass_header Content-Type; proxy_pass_header Content-Disposition; proxy_pass_header Content-Length; } location @fallback { proxy_pass 127.0.0.1:8080; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-for $remote_addr; proxy_set_header Host $host; } } server { listen 80 default; server_name site2.ru; location ~* \.(jpg|jpeg|gif|png|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|tar|wav|bmp|rtf|swf|ico|flv|txt|xml|docx|xlsx)$ { root /var/www/site2.ru; index index.html index.php; access_log off; expires 30d; error_page 404 = @fallback; proxy_cache_valid 404 1m; } location ~ /\.ht { deny all; } location / { proxy_pass 127.0.0.1:8080/; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-for $remote_addr; proxy_set_header Host $host; proxy_connect_timeout 60; proxy_send_timeout 90; proxy_read_timeout 90; proxy_redirect off; proxy_set_header Connection close; proxy_pass_header Content-Type; proxy_pass_header Content-Disposition; proxy_pass_header Content-Length; } location @fallback { proxy_pass 127.0.0.1:8080; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-for $remote_addr; proxy_set_header Host $host; } }
Читать дальше
server { listen 80 default; server_name site1.ru; location ~* \.(jpg|jpeg|gif|png|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|tar|wav|bmp|rtf|swf|ico|flv|txt|xml|docx|xlsx)$ { root /var/www/site1.ru; index index.html index.php; access_log off; expires 30d; error_page 404 = @fallback; proxy_cache_valid 404 1m; } location ~ /\.ht { deny all; } location / { proxy_pass 127.0.0.1:8080/; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-for $remote_addr; proxy_set_header Host $host; proxy_connect_timeout 60; proxy_send_timeout 90; proxy_read_timeout 90; proxy_redirect off; proxy_set_header Connection close; proxy_pass_header Content-Type; proxy_pass_header Content-Disposition; proxy_pass_header Content-Length; } location @fallback { proxy_pass 127.0.0.1:8080; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-for $remote_addr; proxy_set_header Host $host; } } server { listen 80 default; server_name site2.ru; location ~* \.(jpg|jpeg|gif|png|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|tar|wav|bmp|rtf|swf|ico|flv|txt|xml|docx|xlsx)$ { root /var/www/site2.ru; index index.html index.php; access_log off; expires 30d; error_page 404 = @fallback; proxy_cache_valid 404 1m; } location ~ /\.ht { deny all; } location / { proxy_pass 127.0.0.1:8080/; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-for $remote_addr; proxy_set_header Host $host; proxy_connect_timeout 60; proxy_send_timeout 90; proxy_read_timeout 90; proxy_redirect off; proxy_set_header Connection close; proxy_pass_header Content-Type; proxy_pass_header Content-Disposition; proxy_pass_header Content-Length; } location @fallback { proxy_pass 127.0.0.1:8080; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-for $remote_addr; proxy_set_header Host $host; } }