0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[Nginx] nginx.confファイルでドメインを複数指定する方法

Posted at

複数のドメインをカバーする例

nginx.conf
upstream gunicorn {
    server unix:///project_name/tmp/gunicorn_socket;
}

server {
    listen 80;
    server_name api.example.com internal.example.com api.example.test.com internal.example.test.com;
    server_tokens off;

# 省略

複数のドメインをカバーする方法:単にserver_nameに複数のドメインを列挙します

ワイルドカードを使用する例

nginx.conf
upstream gunicorn {
    server unix:///project_name/tmp/gunicorn_socket;
}

server {
    listen 80;
    server_name *.example.com *.example.test.com;
    server_tokens off;

# 省略

ワイルドカードを使用する方法:*.example.comのようにワイルドカードを使用して共通部分をカバーします

正規表現を使用する例

nginx.conf
upstream gunicorn {
    server unix:///project_name/tmp/gunicorn_socket;
}

server {
    listen 80;
    server_name ~^(api|internal)\.example\.(com|test\.com)$;
    server_tokens off;

# 省略

正規表現を使用する方法:server_nameに正規表現を使用して、より柔軟なドメインマッチングを行います

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?