I'm trying to set up multi websites with different ports but same domain. i.e. domain.com, domain.com:81, domain.com:82
Below is the my nginx configuration,
/etc/nginx/sites-enabled/magento225
and
upstream fastcgi_backend {
server unix:/run/php/php7.1-fpm.sock;
}
server {
listen 80;
listen [::]:80;
server_name domain.com;
return 301 https://$server_name$request_uri;
}
server {
listen 81;
listen [::]:81;
server_name domain.com;
return 301 https://$server_name$request_uri;
root /var/www/html/magento226;
location / {
proxy_redirect http://127.0.0.1:81/;
}
}
server {
listen 443 ssl;
server_name domain.com;
ssl on;
ssl_certificate /etc/letsencrypt/live/wpdev1.tk/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/wpdev1.tk/privkey.pem;
set $MAGE_ROOT /var/www/html/magento225;
set $MAGE_MODE developer;
include /var/www/html/magento225/nginx.conf.sample;
}
After that nginx is failed to restart. I tried with removing below piece of code
location {
proxy_redirect http://127.0.0.1:81/;
}
This time nginx can be restarted but website is not working. i.e. domain.com:81
I have enabled the port (81) from the ec2 instance by updating security rule. Any ideas would be appreciated. Thanks.
Update 1:
upstream fastcgi_backend {
server unix:/run/php/php7.1-fpm.sock;
}
server {
listen 80;
listen [::]:80;
server_name domain.com;
root /var/www/html/magento225;
}
server {
listen 81;
listen [::]:81;
server_name domain.com;
root /var/www/html/magento226;
location / {
proxy_pass http://127.0.0.1:81/;
}
}
Tried above configuration and not able to connect 81 port.