assume that VPS IP is 44.55.66.77 , domain name is mydomain.com , VPS system is debian 9
VPS make install
installed nginx,nginx version is 1.15.1 Maginx runs on 80
port, at first nginx.conf
is like this,
...
http {
server {
listen 80;
server_name mydomain.com;
location / {
root html;
index index.html index.htm;
}
}
}
...
now you want to achieve the second-level domain name effect through nginx proxy other ports, such as more.mydomain.com pointing to 8090 port. The configuration is like this,
server {
listen 80;
server_name more.mydomain.com;
location / {
proxy_pass http://127.0.0.1:8090;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
root /usr/local/nginx/html;
index index.html index.htm;
}
}
After nginx reload, visit more.mydomain.com
prompt cannot find the server IP address .
is there a problem with this way of writing? In addition, how to act as an agent after adding ssl module to nginx?
-sharpnginx.conf
server {
listen 80;
server_name mydomain.com;
return 301 https://$host$request_uri;
}