
나는 가지고 있고 Ubuntu 20.04.1 LTS
달리고 있습니다 nginx/1.18.0 (Ubuntu)
.
/etc/nginx/sites-available
요청을 다음으로 라우팅하고 싶기 때문에 기본적으로 내 폴더에 세 개의 구성 파일이 있습니다 .
- myserver.com
- immos.myserver.com
- items.myserver.com
내 myserver.com
구성 파일은 다음과 같습니다.
server {
server_name myserver.com www.myserver.com;
root /var/www/main-application/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.html index.htm index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/myserver.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/myserver.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = www.myserver.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = myserver.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name myserver.com www.myserver.com nlg.myserver.com;
return 404; # managed by Certbot
}
내 nginx-config는 immos.myserver.com
다음과 같습니다.
server {
listen 80;
server_name immos.myserver.com;
root /var/www/immos-application/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.html index.htm index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
내 nginx 구성은 items.myserver.com
다음과 같습니다.
server {
listen 80;
server_name items.myserver.com;
root /var/www/items_application/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.html index.htm index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
모든 하위 도메인과 도메인은 DNS에서 내 서버의 IP로 라우팅됩니다.
열어서 myserver.com
올바른 페이지로 이동할 수 있습니다.
immos.myserver.com
하지만 을 열면 에서 items.myserver.com
실행 중인 애플리케이션으로 라우팅됩니다 myserver.com
.
세 가지 애플리케이션은 모두 laravel 애플리케이션입니다.
내가 뭘 잘못하고 있는지 어떤 제안이 있습니까?