nginx proxy_pass wordpress on apache with Two separated server - wordpress

I have a nginx server with domain name[www.sample.com] and IP adress [1.1.1.1].
Also I have an apache Server that contains WordPress with ip[2.2.2.2].
Nginx Configured to proxy_pass www.sample.com/app to 2.2.2.2/ap.
WordPress loads paths, but could not load Css Resource on wordpress wp-include

Related

Nginx Proxy Manager to host site

I am using NPM to configure my subdomains and redirect them to my containers.
My problem is that I cannot do the same with the main domain.
I am using nginx server with php for my site, after configuring a proxy host to test.example.com it is working flawlessly, but if I configure the same for example.com or www.example.com, I am not able to open my site.
I've uploaded my certificate to npm as a custom certificate and assigned it to the example.com proxy host, but it's not working.
If I open http://example.com I get the "Congratulations" page from NPM.
How can I make my site example.com working identical as test.example.com?
I've tried following in my nginx conf:
ssl on;
ssl_certificate /path;
ssl_certificate_key /path;
changing the server_name;

Howto point two domainnames to one website in nginx

I have an NGINX webserver, which is serving multiple websites. For each website, I have a seperate nginx configuration file in the /etc/nginx/sites-available folder.
Now, I would like to have two domainnames (aaa.com and bbb.com) point to the same website. On the registrar side both domain names point to the IP address of my webserver.
On nginx, I have the following configuration:
server {
listen 443 ssl http2;
root /var/www/html/aaa.com/public_html;
index index.html index.php index.htm;
server_name aaa.com www.aaa.com bbb.com www.bbb.com;
<rest of the configuration
}
I can reach now www.aaa.com but accessing the website via bbb.com does not work.
Should I create a seperate config file (in sites-available) for bbb.com and point to the location of the website in /var/www/html and enable it in sites-enabled?

Nginx reverse proxy not working to Shiny Server hosted on AWS Lightsail Instance

I am new to nginx and am trying to configure a reverse proxy to a Shiny Server (Open) that I have successfully implemented on an AWS Lightsail Instance. I am desperate at this point and would appreciate any advice. Here are the pertinent configuration arrangements.
Note that I have a purchased a custom domain from GoDaddy. Assume this is named mydomain.com.au. However, I have changed the name servers to point to Netlify as I deployed my website through the blogdown R package in Netlify.
Lightsail Instance Details
This has a Shiny Server installed and a static IP address assigned. Assume 123.45.67.89 from this point onwards. The firewall details are provided below:
Lightsail instance firewall details
I can successfully access the Shiny Server via http://123.45.67.89:3838 and associated Shiny apps I've deployed. I have a DNS Zone record added in order to link mydomain.com.au to my Shiny Server on the Lightsail instance - see details below:
Record Type: A
Subdomain: shiny.mydomain.com.au
Resolves to: 123.45.67.89 (i.e. static IP address)
Netlify details
I have a DNS record added in Netlify for mydomain.com.au which points to the Lightsail instance static IP address. Below are the details (I'm not sure whether I need a DNS record in Netlify and Lightsail though). Note this this is SSL/TLS certificate enabled and cannot be disabled (it will automatically revert to "https://" even when "http://" is specified).
Name: shiny.mydomain.com.au
TTL: 3600 seconds
Type: A
Value: 123.45.67.89
nginx details
Below are the relevant details of the /etc/nginx/sites-enabled/default file which I modified based on the instructions from this post. The $http_upgrade and $connection_upgrade is stored in the /etc/nginx/nginx.conf file. There is no SSL/TLS certificate from certbot added and I'm not sure whether this is an issue.
server {
listen [::]:80 default_server;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name shiny.mydomain.com.au;
# Reverse proxy to port 3838
location / {
proxy_pass http://localhost:3838/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_read_timeout 20d;
proxy_buffering off;
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
# try_files $uri $uri/ =404;
}
The nginx configuration test appears to be successful:
sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
The following firewall profiles (from sudo ufw status) are set up - Nginx HTTP, OpenSSH, 3838 and 80. nginx is active and running too with no issues according to sudo service nginx status.
What works?
http://123.45.67.89:3838/ successfully opens the Shiny Server index page.
https://shiny.mydomain.com.au:3838/ successfully opens the Shiny Server index page.
Other information?
Visiting https://shiny.mydomain.com.au:3838 will automatically attempt https://123.45.67.89:443 which ultimately fails and times out. The redirection to 123.45.67.89 appears to work but it does not forward to the 3838 port. Firefox Network monitoring indicates that the Server is nginx.
What might be happening?
At this point (and I am very new to web administration), I think this might be an issue with Netlify forcing HTTPS which cannot be redirect to the Shiny Server port (HTTP?). However, visiting https://shiny.mydomain.com.au:3838 successfully redirects to the Shiny Server index page. I just can't understand why nginx isn't successfully forwarding to the 3838 port without specifying it in the URL based on the default configuration file.
What is the problem?
Loading shiny.mydomain.com.au does not successfully load the Shiny Server index page. It will eventually time out and no page is loaded ("The connection has timed out"). Checking the network monitoring information in Firefox indicates that tries to access 123.45.67.89 but not 123.45.67.89:3838 (i.e. the Shiny Server). It doesn't appear that it is redirecting at all according to the /etc/nginx/sites-enabled/default file.
I have tried changing localhost to 127.0.0.1 to no avail. I have tried following Dean Attali's post and another recent post on setting up Shiny Server too but still no success.
Can someone please help me out on how to get nginx as a reverse proxy to work?
I'm really running out of ideas here. Thanks.

Nginx vhosts per path

How do I setup nginx conf so that "blah.com/website1" and "blah.com/website2" etc can point to separate websites that are running on the machine (vhost?)?
E.g. localhost:3000 is website1 and localhost:3001 is website2.
So when a user points their browser at blah.com/website1 they access the website localhost:3000 and localhost:3001 for website2?
I've tried a reverse proxy but that can't map paths like "blah.com/website1" and only seems to handle the server name of "blah.com".
Update:
So I've tried a config like this to use reverse proxy, but all assests on the website are not loading as they are trying to load from the domain's root. Probably because it's not a vhost? The page loads but assets are trying to load and 404ing, e.g: http://blah.com/static/css/styles.css
server {
listen 80;
server_name blah.com;
location /website1/ {
proxy_pass http://localhost:3001/;
}
}

Nginx does not serve the flask pages and shows the default static page

I have a flask app running with gunicorn and nginx on Ubuntu 14.04 using AWS EC2. I have deleted default site from /etc/nginx/sites-available and /etc/nginx/sites-enabled. In those two folders, there is only one file: flasky - my nginx file as below:
server {
listen 80;
location / {
include proxy_params;
proxy_pass http://unix:/tmp/flasky.sock;
}
When I enter the IP of the server in the browser, the default Nginx static page shows up. If I go to /auth/login, the correct page served by Flask shows up properly.
If the change the port from 80 to 8080, restart Nginx, enter http://ip-address:8080 then all Flask pages work well. I don't know how to fix this for port 80. Please help! Thanks!
UPDATE: I just found out that if I use the AWS Public DNS: http://ec2-50-112-125-180.us-west-2.compute.amazonaws.com, it works. But if I use the corresponding Elastic IP: 50.112.125.180 it shows the nginx default page. Anyone knows why?
Search your nginx.conf for the word include
maybe it's including other directories for config files.
Also, there may be other config blocks with
location /
that is superseding this section that also have listen 80.

Resources