Configuration – use the subdomain configuration nginx

I have completed my previous research, but I can’t seem to find out how to properly configure nginx to accept subdomains.

I am currently correct for mydomain.com Configure, but not analyze.mydomain.com:

server {
listen 80;
server_name *.mydomain.com;
access_log / home/ubuntu/virtualenv/mydomain/error/access.log;
error_log /home/ubuntu/virtualenv/mydomain/error/error.log warn;
connection_pool_size 2048;

fastcgi_buffer_size 4K;
fastcgi_buffers 64 4k;

root /home/ubuntu/virtualenv/mydomain/homelaunch/;

location /static/ {
alias /home/ubuntu/virtualenv/mydomain/homelaunch/static/;
}

location / {
proxy_pass http://127.0.0.1:8001;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
add_header P3P'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"';
}
}

The server_name statement accepts .mydomain.com which is good.

If I visit analytix.mydomain.com, it will throw Http 500 The default value, which is good because it throws it from the existing application of mydomain.com

The domain name has been propagated to the server where I am trying to access it.

How to specify a folder in the path to store the content of analytix.mydomain.com? I think I will ask to change the attributes in nginx conf (as shown above)

create a new Server block, set server_name to the desired domain. The general directory and file structure of nginx is as follows:

/etc/nginx
|
|---- /sites-available
| |
| |---- default.conf
|
|---- /sites-enabled
|
|---- default.conf -> ../sites-available/default.conf

You must create a new file in the site-which contains the new server block In your subdomain, create a symbolic link to this new file at the location of the active site. A simple reload of nginx will start your new server.

Your new file structure looks like this:

/etc/nginx
|
|---- /sites-available
| |
| |-- - analytix.conf
| |
| |---- default.conf
|
|---- /sites-enabled
|
|---- analytix.conf -> ../sites-available/analytix.conf
|
|---- default.conf -> ../sites-available/default.conf

The following are the commands involved in performing this operation directly on your server:

# cd /etc/nginx/sites-available
# cat default.conf> analytix.conf
# editor analytix.conf

Change the line server_ name * .mydomain.com; to server_name analytix.mydomain.com.

# ln -s analytix.conf ../sites-enabled/
# nginx- t

Only continue when you say that your configuration is ok (it should be).

# service nginx restart

That’s it (please note that all the above commands are applicable to Debian-based distributions, some commands may be different if other content is used).

In order to provide the content of different software on the server , You must change the root directive in the configuration and point it to the document root directory of other software.

# editor analytix.conf

Change root / home /ubuntu/virtualenv/mydomain/homelaunch/;Go to root/path/to/other/software; and reload your nginx.

# nginx -t && service nginx reload 

That’s it, your new application should now be served.

I have completed my previous research, but I can’t seem to find out how to configure nginx properly To accept subdomains.

I currently have the correct configuration for mydomain.com, but not analyze.mydomain.com:

server {< br /> listen 80;
server_name *.mydomain.com;
access_log /home/ubuntu/virtualenv/mydomain/error/access.log;
error_log /home/ubuntu/virtualenv/mydomain /error/error.log warn;
connection_pool_size 2048;

fastcgi_buffer_size 4K;
fastcgi_buffers 64 4k;

root /home/ubuntu/virtualenv/mydomain/homelaunch/;

location /static/ {
alias /home/ubuntu/virtualenv/mydomain/homelaunch/static/;
}

location / {
proxy_pass http://127.0.0.1:8001;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
add_header P3P'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"';
}
}

The server_name statement accepts .mydomain.com which is good.

If I visit analyze.mydomain.com, it will throw the Http 500 default value, which is very Good because it throws it from the existing application of mydomain.com

The domain name has been propagated to the server where I am trying to access it.

How to specify in the path Folder to store the content of analytix.mydomain.com? I think I will ask to change the properties in nginx conf (as shown above)

Create a new server block and set server_name to the desired domain. The general directory and file structure of nginx is as follows:

/etc/nginx
|
|---- /sites-available
| |
| |---- default.conf
|
|---- /sites-enabled
|
|---- default .conf -> ../sites-available/default.conf

You must create a new file in the site – it contains the new server block for your subdomain and where the site is enabled Create a symbolic link to this new file. A simple reload of nginx will start your new server.

The structure of your new file looks like this:

< pre>/etc/nginx
|
|—- /sites-available
| |
| |—- analytix.conf
| |< br />| |—- default.conf
|
|—- /sites-enabled
|
|—- analytix.conf ->. ./sites-available/analytix.conf
|
|—- default.conf -> ../sites-available/default.conf

The following is directly in your The commands involved in performing this operation on your server:

# cd /etc/nginx/sites-available
# cat default.conf> analytix.conf
# editor analytix.conf

Change the line server_name * .mydomain.com; to server_name analytix.mydomain.com.

# ln -s analytix.conf ../sites-enabled/
# nginx -t

Only when you say that your configuration is OK Continue (it should be like this).

# service nginx restart

That’s it (please note that all the above commands are applicable to Debian-based distributions, If you use other content, some commands may be different).

In order to provide the content of different software on the server, you must change the root directive in the configuration and point it to the document root directory of the other software .

# editor analytix.conf

Change root / home / ubuntu / virtualenv / mydomain / homelaunch /; to root / path / to / other / software; and reload your nginx.

# nginx -t && service nginx reload

That’s it, your new application should now serve.

Leave a Comment

Your email address will not be published.