When I try www.abc.com it works but when i try www.abc.com/def or www.abc.com/ghi/ get 404 error.
Here is my nginx config
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name www.abc.com;
location / {
proxy_pass http://I/;
}
location /def{
proxy_pass http://oid-global-windows/;
}
location /ghi/ {
proxy_pass http://oid-global-windows/;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
I tried to tweak the config with alias instead of proxy_pass still no luck. BTW, oid-global-windows is a docker container name and nginx is in another container hosted in same windoes server.
The setup I followed was as per this link -
https://www.mihajakovac.com/run-nginx-webserver-in-docker-on-windows/
Related
I have a statically served React application with Nginx.
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 3000;
server_name localhost;
root /usr/share/nginx/html;
location ^~ /static/ {
root /usr/share/nginx/html/;
}
location / {
try_files $uri /index.html;
index index.html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
During build (with Vite) we produce source maps which are served in development.
For specific environments (stage.* and app.* but not dev.*) I would like to not serve the source maps.
I have no option to not build source maps for these environments in the first place, because we migrate entire builds between environments.
I want to use Nginx to not serve *.map files out of /static for these environments.
How would I do that?
I have a React app that runs on https://localhost:3000.
I have a domain like https://example.com/some/path.
When I enter https://example.com/some/path into my browser, I'd like it to redirect to https://localhost:3000. So the way I've seen this possible is using a reverse proxy and I'm trying to nginx setup to do so.
However I keep facing in an issue that I need include the port number when I go to the full url for example: https://example.com:3000/some/path.
How do i prevent this from happening? i.e. I'd like to just enter https://example.com/some/path.
My nginx conf file looks like this:
#user nobody;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 443 ssl;
server_name example.com;
ssl_certificate cert.pem;
ssl_certificate_key cert.key;
location /some/path {
return 301 $scheme://localhost:3000$request_uri;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 3000 ssl;
ssl_certificate cert.pem;
ssl_certificate_key cert.key;
server_name localhost;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
location / {
proxy_pass https://localhost:3000;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
include servers/*;
}
And in my hosts file I have the line:
127.0.0.1 example.com
Even if I keep it simple and have only one server section with location like:
location /some/path {
proxy_pass https://localhost:3000;
}
That kind of works - however looking at the console the assets themselves don't load https://example.com/static/js/bundle.js when it needs to be https://example.com:3000/static/js/bundle.js
Any help would be appreciated.
I thought this Nginx setup was supposed to be easy :( I can get my index.html to load on localhost only but when I try to access the site by my domain name it doesn't work, or even if I try the server IP address externally it doesn't resolve :( What am I doing wrong? The is on Windows. Here is my conf;
#user nobody;
worker_processes auto;
events {
worker_connections 2048;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 5;
#gzip on;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
# root html;
root C:/xampp/htdocs;
index index.php index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
the issue was that I didn't enable Nginx in the Windows Firewall. Working now.
Hello I started using nginx, set up the nginx.conf to my project folder C: / Projects.
I used (AutoIndex: on) to have a list of directories, but does not work
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
server {
listen 80;
server_name localhost;
root C:\Project ;
index index.html index.htm index.php;
location / {
autoindex on;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
Move your autoindex on; outside your location block
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
server {
listen 80;
server_name localhost;
root C:\Project ;
index index.html index.htm index.php;
# moved here
autoindex on;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
If you have one of the index files present inside your root directory (or any subdirectory under C:\Project for that matter), the index page will be shown rather than the index of contents.
You may also want to check the permissions on all content under your root; they need to be readable by the user running your Nginx process.
Could be a number of different things; you'll need to clarify your questions in future with what you've tried and haven't tried.
After successful login, securedsocial redirect to the URL http://sss/ instead of http://ip:9009. The proxy_pass works fine except when logging to the system with securedsocial.Any fix to this?
NGIXIN.conf
upstream sss {
server ip:9009;
}
SecuredSocial.conf
onLoginGoTo=/
worker_processes auto;
events {
worker_connections 20000;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
upstream playserver {
server 127.0.0.1:9009;
}
server {
listen 80;
server_name localhost;
access_log off;
location / {
proxy_pass http://playserver;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}