--------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------
1) Redirect non-www to www
return 301 $scheme://www.example.com$request_uri;
2) Redirect www to non-www
return 301 $scheme://example.com$request_uri;
3) http to https
return 301 https://www.example.com$request_uri;
--------------------------------------------------------------------------------------------------
for accessing localhost/info.php following below commands
--------------------------------------------------------------------------------------------------
sudo apt-get install php-fpm php-mysqli
sudo vim /etc/php/7.0/fpm/php.ini -------php.ini configuration file
sudo service php7.0-fpm restart -------Restart php fpm
sudo service nginx restart
sudo ln -s /etc/nginx/site-available/tech2towards.conf /etc/nginx/site-enabled -------create symlink
--------------------------------------------------------------------------------------------------
nginx webserver virtual host file.
--------------------------------------------------------------------------------------------------
server {
listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:80 default_server;
server_name tech2towards.com;
root /var/www/html/Production/;
index index.php index.html index.htm index.nginx-debian.html;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
--------------------------------------------------------------------------------------------------
wildcard subdomain entry for nginx webserver.
--------------------------------------------------------------------------------------------------
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name ~^(?<subdomain>[^.]+).tech2towards.tech;
root /var/www/html/$subdomain;
index index.php index.html index.htm index.nginx-debian.html;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
}
}
/var/www/html/stage2
/var/www/html/admin
/var/www/html/blog
--------------------------------------------------------------------------------------------------
NGINX Reverse Proxy For React And Node
--------------------------------------------------------------------------------------------------
server {
listen 80 default_server;
listen [::]:80 default_server;
#This Proxy For Frontend-React Ex: http://example.com
location / {
proxy_pass http://localhost:3001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
#This Proxy For Backend-Node Ex: Ex: http://example.com/Backend
location /Backend {
proxy_pass http://localhost:3002;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
--------------------------------------------------------------------------------------------------
server {
listen 80 ;
server_name example.com;
location / {
proxy_pass http://localhost:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
--------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------
No comments:
Post a Comment
testing