nginx 2 vhost
HejJeg har 2 sidder jeg gerne vil have op og køre og er ny til nginx, har normalt brugt apache. Men lige meget hvordan jeg bærer mig ad, så kan jeg ikke få det til at virke.
Håber at der er nogen der kan hjælpe mig.
vhost 1:
## our http server at port 80
server {
listen 80;
server_name domain1.com www.domain1.com;
## redirect http to https ##
rewrite ^ https://$server_name$request_uri? permanent;
}
## Our https server at port 443. You need to provide ssl config here###
server {
access_log /path/access_log;
error_log /path/error_log;
index index.html index.htm index.php;
root /path;
## start ssl config ##
listen 443 ssl;
server_name domain1.com www.domain1.com;
## redirect www to nowww
#if ($host = 'www.example.com' ) {
#rewrite ^/(.*)$ https://example.com/$1 permanent;
#}
### ssl config - customize as per your setup ###
ssl_certificate /path/ssl.crt;
ssl_certificate_key /path/.key;
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers RC4:HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
keepalive_timeout 70;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
## PROXY backend
location / {
add_header Front-End-Https on;
add_header Cache-Control "public, must-revalidate";
add_header Strict-Transport-Security "max-age=2592000; includeSubdomains";
proxy_pass http://127.0.0.1:9000;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location ~ \.php$ {
try_files $uri =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;
}
#location ~ ^/stash {
#proxy_pass http://1234:7990;
#proxy_set_header Host $host;
#proxy_set_header X-Real-IP $remote_addr;
#proxy_set_header X-Forwarded-for $remote_addr;
#port_in_redirect off;
#proxy_redirect http://1234:7990/ /stash;
#proxy_connect_timeout 300;
#}
}
vhost 2:
server {
listen 80;
server_name domain2.com www.domain2.com;
## redirect http to https ##
rewrite ^ https://$server_name$request_uri? permanent;
}
## Our https server at port 443. You need to provide ssl config here###
server {
access_log /path/access_log;
error_log /path/error_log;
index index.html index.htm index.php;
root /path;
## start ssl config ##
listen 443 ssl;
server_name domain2.com www.domain2.com;
## redirect www to nowww
#if ($host = 'www.example.com' ) {
#rewrite ^/(.*)$ https://example.com/$1 permanent;
#}
### ssl config - customize as per your setup ###
ssl_certificate /path/ssl.crt;
ssl_certificate_key /path/.key;
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers RC4:HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
keepalive_timeout 70;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
## PROXY backend
location / {
add_header Front-End-Https on;
add_header Cache-Control "public, must-revalidate";
add_header Strict-Transport-Security "max-age=2592000; includeSubdomains";
proxy_pass http://127.0.0.1:9000;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location ~ \.php$ {
try_files $uri =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;
}
#location ~ ^/stash {
#proxy_pass http://1234:7990;
#proxy_set_header Host $host;
#proxy_set_header X-Real-IP $remote_addr;
#proxy_set_header X-Forwarded-for $remote_addr;
#port_in_redirect off;
#proxy_redirect http://1234:7990/ /stash;
#proxy_connect_timeout 300;
#}
}
Mange tak på forhånd